zeus
4 years ago
14 changed files with 0 additions and 292 deletions
@ -1,44 +0,0 @@ |
|||
|
|||
function swarmlab_ifup() { |
|||
swarmlab=$(/bin/bash /data/appl/ok/swarmlab-hybrid-agent/src-local/hybrid/connect/status.sh wg0 | jq .swarmlab) |
|||
tempswarm="${swarmlab%\"}" |
|||
tempswarm="${tempswarm#\"}" |
|||
swarmlab=$tempswarm |
|||
echo $swarmlab |
|||
} |
|||
function hybrid_ifup() { |
|||
hybrid=$(/bin/bash /data/appl/ok/swarmlab-hybrid-agent/src-local/hybrid/connect/status.sh wg0 | jq .hybrid) |
|||
tempswarm1="${hybrid%\"}" |
|||
tempswarm1="${tempswarm1#\"}" |
|||
hybrid=$tempswarm1 |
|||
echo $hybrid |
|||
} |
|||
|
|||
hybrid=$(hybrid_ifup) |
|||
if [ $hybrid == 'NotOnline' ]; then |
|||
/bin/bash /data/appl/ok/swarmlab-hybrid-agent/src-local/hybrid/connect/swarmlab-connect.sh |
|||
sleep 2 |
|||
hybrid1=$(hybrid_ifup) |
|||
if [ $hybrid1 == 'NotOnline' ]; then |
|||
echo "Failed to start wg0 network interface" |
|||
else |
|||
echo "Swarmlab hybrid $hybrid" |
|||
fi |
|||
else |
|||
echo "Swarmlab hybrid $hybrid" |
|||
fi |
|||
|
|||
swarmlab=$(swarmlab_ifup) |
|||
if [ $swarmlab != 'active' ]; then |
|||
sleep 1 |
|||
swarmlab1=$(swarmlab_ifup) |
|||
if [ $swarmlab1 != 'active' ]; then |
|||
echo "Failed to connect on swarmlab master" |
|||
echo "Exec " |
|||
echo "/bin/bash /data/appl/ok/swarmlab-hybrid-agent/src-local/hybrid/connect/reload-swarmlab.sh" |
|||
echo "Please try again" |
|||
fi |
|||
else |
|||
echo "Swarmlab master $swarmlab" |
|||
fi |
|||
|
@ -1,43 +0,0 @@ |
|||
|
|||
function swarmlab_ifup() { |
|||
swarmlab=$(/bin/bash /data/appl/ok/swarmlab-hybrid-agent/src-local/hybrid/connect/status.sh wg0 | jq .swarmlab) |
|||
tempswarm="${swarmlab%\"}" |
|||
tempswarm="${tempswarm#\"}" |
|||
swarmlab=$tempswarm |
|||
echo $swarmlab |
|||
} |
|||
function hybrid_ifup() { |
|||
hybrid=$(/bin/bash /data/appl/ok/swarmlab-hybrid-agent/src-local/hybrid/connect/status.sh wg0 | jq .hybrid) |
|||
tempswarm1="${hybrid%\"}" |
|||
tempswarm1="${tempswarm1#\"}" |
|||
hybrid=$tempswarm1 |
|||
echo $hybrid |
|||
} |
|||
|
|||
hybrid=$(hybrid_ifup) |
|||
if [ $hybrid == 'NotOnline' ]; then |
|||
/bin/bash /data/appl/ok/swarmlab-hybrid-agent/src-local/hybrid/connect/swarmlab-connect.sh |
|||
sleep 2 |
|||
hybrid1=$(hybrid_ifup) |
|||
if [ $hybrid1 == 'NotOnline' ]; then |
|||
echo "Failed to start wg0 network interface" |
|||
else |
|||
echo "Swarmlab hybrid $hybrid" |
|||
fi |
|||
else |
|||
echo "Swarmlab hybrid $hybrid" |
|||
fi |
|||
|
|||
swarmlab=$(swarmlab_ifup) |
|||
if [ $swarmlab != 'active' ]; then |
|||
sleep 1 |
|||
swarmlab1=$(swarmlab_ifup) |
|||
if [ $swarmlab1 != 'active' ]; then |
|||
echo "Failed to connect on swarmlab master" |
|||
echo "Exec " |
|||
echo "/bin/bash /data/appl/ok/swarmlab-hybrid-agent/src-local/hybrid/connect/reload-swarmlab.sh" |
|||
echo "Please try again" |
|||
fi |
|||
else |
|||
echo "Swarmlab master $swarmlab" |
|||
fi |
@ -1,23 +0,0 @@ |
|||
function hybrid_ifup() { |
|||
hybrid=$(/bin/bash /data/appl/ok/swarmlab-hybrid-agent/src-local/hybrid/connect/status.sh wg0 | jq .hybrid) |
|||
tempswarm1="${hybrid%\"}" |
|||
tempswarm1="${tempswarm1#\"}" |
|||
hybrid=$tempswarm1 |
|||
echo $hybrid |
|||
} |
|||
|
|||
hybrid=$(hybrid_ifup) |
|||
if [ $hybrid == 'NotOnline' ]; then |
|||
echo "Swarmlab hybrid $hybrid" |
|||
else |
|||
ip link set wg0 down |
|||
ip link del wg0 |
|||
sleep 3 |
|||
hybrid1=$(hybrid_ifup) |
|||
if [ $hybrid1 == 'NotOnline' ]; then |
|||
echo "Swarmlab hybrid $hybrid" |
|||
else |
|||
echo "Swarmlab hybrid $hybrid" |
|||
fi |
|||
fi |
|||
|
@ -1,23 +0,0 @@ |
|||
|
|||
function hybrid_ifup() { |
|||
hybrid=$(/bin/bash /data/appl/ok/swarmlab-hybrid-agent/src-local/hybrid/connect/status.sh wg0 | jq .hybrid) |
|||
tempswarm1="${hybrid%\"}" |
|||
tempswarm1="${tempswarm1#\"}" |
|||
hybrid=$tempswarm1 |
|||
echo $hybrid |
|||
} |
|||
|
|||
hybrid=$(hybrid_ifup) |
|||
if [ $hybrid == 'NotOnline' ]; then |
|||
echo "Swarmlab hybrid $hybrid" |
|||
else |
|||
ip link set wg0 down |
|||
ip link del wg0 |
|||
sleep 3 |
|||
hybrid1=$(hybrid_ifup) |
|||
if [ $hybrid1 == 'NotOnline' ]; then |
|||
echo "Swarmlab hybrid $hybrid" |
|||
else |
|||
echo "Swarmlab hybrid $hybrid" |
|||
fi |
|||
fi |
@ -1 +0,0 @@ |
|||
uHuqIEOoQTsESNhiz7Uu1COJlbIHdruBiMUG1GvBTHM= |
@ -1 +0,0 @@ |
|||
ol5eKuHsOOAY9mWpVnsVTG+EODv8Hcl8bMobkNx4Si8= |
@ -1,16 +0,0 @@ |
|||
|
|||
function ifup { |
|||
if [[ ! -d /sys/class/net/${1} ]]; then |
|||
#printf 'No such interface: %s\n' "$1" >&2 |
|||
return 1 |
|||
else |
|||
[[ $(</sys/class/net/${1}/operstate) == up ]] |
|||
fi |
|||
} |
|||
|
|||
if ifup $1; then |
|||
echo Online |
|||
else |
|||
echo 'Not online' |
|||
fi |
|||
|
@ -1,37 +0,0 @@ |
|||
|
|||
|
|||
function ifup { |
|||
if [[ ! -d /sys/class/net/${1} ]]; then |
|||
return 1 |
|||
else |
|||
[[ $(</sys/class/net/${1}/carrier) == 1 ]] |
|||
fi |
|||
} |
|||
|
|||
if ifup $1; then |
|||
hybridswarm='Online' |
|||
else |
|||
hybridswarm='NotOnline' |
|||
fi |
|||
|
|||
|
|||
dockerswarm=$(docker info --format "{{json .}}" | jq .Swarm.LocalNodeState) |
|||
tempswarm="${dockerswarm%\"}" |
|||
tempswarm="${tempswarm#\"}" |
|||
dockerswarm=$tempswarm |
|||
|
|||
dockerswarmid=$(docker info --format "{{json .}}" | jq .Swarm.NodeID) |
|||
tempswarm1="${dockerswarmid%\"}" |
|||
tempswarm1="${tempswarm1#\"}" |
|||
swarmlabid=$tempswarm1 |
|||
#echo $dockerswarm |
|||
#echo $hybridswarm |
|||
#echo $swarmlabid |
|||
|
|||
#jq --arg key0 'swarmlab' --arg swarmlab $dockerswarm --arg key1 'hybrid' --arg hybrid $hybridswarm --arg key2 'swarmlabid' --arg swarmlabid $swarmlabid'. | .[$key0]=$swarmlab | .[$key1]=$hybrid | .[$key2]=$swarmlabid' <<<'{}' |
|||
jq \ |
|||
--arg key0 'swarmlab' --arg swarmlab $dockerswarm \ |
|||
--arg key1 'hybrid' --arg hybrid $hybridswarm \ |
|||
--arg key2 'swarmlabid' --arg swarmlabid $swarmlabid \ |
|||
'. | .[$key0]=$swarmlab | .[$key1]=$hybrid | .[$key2]=$swarmlabid' <<<'{}' |
|||
|
@ -1,33 +0,0 @@ |
|||
|
|||
DEV_NAME=wg0 |
|||
INTERFACE_IP=10.13.13.2/16 |
|||
INTERFACE_IProute=10.13.13.2 |
|||
ENDPOINT_IP=83.212.77.133 |
|||
|
|||
ip link set $DEV_NAME down |
|||
ip link del $DEV_NAME |
|||
# add wireguard interface |
|||
ip link add $DEV_NAME type wireguard |
|||
|
|||
# set wireguard conf |
|||
wg setconf $DEV_NAME /data/appl/ok/swarmlab-hybrid-agent/src-local/hybrid/connect/$DEV_NAME.conf |
|||
|
|||
# assign ip to wireguard interface |
|||
ip addr add $INTERFACE_IP dev $DEV_NAME |
|||
|
|||
# set sysctl |
|||
sysctl -w net.ipv4.conf.all.rp_filter=2 |
|||
|
|||
# set mtu for wireguard interface |
|||
ip link set mtu 1420 up dev $DEV_NAME |
|||
|
|||
# bring wireguard interface up |
|||
ip link set up dev $DEV_NAME |
|||
|
|||
# add route |
|||
ip route add default via $INTERFACE_IProute metric 2 table 200 |
|||
ip route show table 200 | grep -w $INTERFACE_IProute |
|||
|
|||
# add local lan route |
|||
ip rule add table main suppress_prefixlength 0 |
|||
ip rule show | grep -w "suppress_prefixlength" |
@ -1,38 +0,0 @@ |
|||
|
|||
DEV_NAME=wg0 |
|||
#INTERFACE_IP=10.13.13.2/24 |
|||
INTERFACE_IP=10.13.13.2/16 |
|||
INTERFACE_IProute=10.13.13.2 |
|||
ENDPOINT_IP=`grep Endpoint /etc/wireguard/$DEV_NAME.conf | awk '{print $3}' | cut -d: -f1` |
|||
|
|||
echo "ip $INTERFACE_IP" |
|||
|
|||
ip link set $DEV_NAME down |
|||
ip link del $DEV_NAME |
|||
# add wireguard interface |
|||
ip link add $DEV_NAME type wireguard |
|||
|
|||
# set wireguard conf |
|||
wg setconf $DEV_NAME /etc/wireguard/$DEV_NAME.conf |
|||
|
|||
|
|||
# assign ip to wireguard interface |
|||
ip addr add $INTERFACE_IP dev $DEV_NAME |
|||
|
|||
# set sysctl |
|||
sysctl -w net.ipv4.conf.all.rp_filter=2 |
|||
|
|||
# set mtu for wireguard interface |
|||
ip link set mtu 1420 up dev $DEV_NAME |
|||
|
|||
# bring wireguard interface up |
|||
ip link set up dev $DEV_NAME |
|||
|
|||
# add route |
|||
ip route add default via $INTERFACE_IProute metric 2 table 200 |
|||
ip route show table 200 | grep -w $INTERFACE_IProute |
|||
|
|||
# add local lan route |
|||
ip rule add table main suppress_prefixlength 0 |
|||
ip rule show | grep -w "suppress_prefixlength" |
|||
|
@ -1,2 +0,0 @@ |
|||
|
|||
docker swarm join --token SWMTKN-1-3099nls9my5ns1s0mnmwkx41mhpawl80hwjjbskbll7nghqhgn-asu68y4lhd1qlbpxr6oosk6wl 10.13.13.1:2377 |
@ -1,10 +0,0 @@ |
|||
[Interface] |
|||
PrivateKey = kJd3ga9/1b5NalONMP+CuezTZB+ZmaQVdzM7jLYUe30= |
|||
ListenPort = 51820 |
|||
|
|||
[Peer] |
|||
PublicKey = WAuzcpIf1obckeLP94owls31j58LP2k+yIAasx9VFU8= |
|||
Endpoint = 83.212.77.133:51820 |
|||
AllowedIPs = 10.13.13.0/16, 0.0.0.0/0, ::/0 |
|||
PersistentKeepalive = 30 |
|||
|
@ -1,11 +0,0 @@ |
|||
[Interface] |
|||
PrivateKey = CCJXNalGbNIDK5oz5IG8lGuQFATfEcSILw7tWqNO9U4 |
|||
ListenPort = 51820 |
|||
|
|||
[Peer] |
|||
#PublicKey = WAuzcpIf1obckeLP94owls31j58LP2k+yIAasx9VFU8= |
|||
PublicKey = yMTjzSFQloNH22v+sN9k4cIaOUujq/m+vB2HJdJM7GI= |
|||
Endpoint = 83.212.77.133:51820 |
|||
AllowedIPs = 10.13.13.0/24, 0.0.0.0/0, ::/0 |
|||
PersistentKeepalive = 30 |
|||
|
@ -1,10 +0,0 @@ |
|||
[Interface] |
|||
PrivateKey = kJd3ga9/1b5NalONMP+CuezTZB+ZmaQVdzM7jLYUe30= |
|||
ListenPort = 51820 |
|||
|
|||
[Peer] |
|||
PublicKey = WAuzcpIf1obckeLP94owls31j58LP2k+yIAasx9VFU8= |
|||
Endpoint = 83.212.77.133:51820 |
|||
AllowedIPs = 10.13.13.0/16, 0.0.0.0/0, ::/0 |
|||
PersistentKeepalive = 30 |
|||
|
Loading…
Reference in new issue