From 299acefb3e36bc499e06464580fc47f25919b9a6 Mon Sep 17 00:00:00 2001 From: stebifan Date: Sun, 28 Feb 2016 00:13:18 +0100 Subject: [PATCH 1/3] Update keepalive.exit.sh.j2 --- files/keepalive.exit.sh.j2 | 85 +++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 25 deletions(-) diff --git a/files/keepalive.exit.sh.j2 b/files/keepalive.exit.sh.j2 index a99b670..450bc9b 100644 --- a/files/keepalive.exit.sh.j2 +++ b/files/keepalive.exit.sh.j2 @@ -1,29 +1,64 @@ -#!/bin/sh -# -# -q quiet -# -c nb of pings - -HOST1=8.8.8.8 -HOST2=8.8.4.4 +#!/bin/bash +#Variablen +iam=$(/bin/hostname) BATCTL=/usr/local/sbin/batctl - -ping -q -c5 $HOST1 > /dev/null -if [ $? -eq 0 ] +SN1=troisdorf5 +SN2=troisdorf6 +if [ $iam == troisdorf5 ] then - echo "ok" - $BATCTL gw server 100Mbit/100Mbit + my_SN_IP=185.66.193.105 + other_SN_IP=185.66.193.106 else - - echo "$HOST1 NICHT ok" - ping -q -c5 $HOST2 > /dev/null - if [ $? -eq 0 ] - then - echo "$HOST2 ok" - $BATCTL gw server 100Mbit/100Mbit - else - echo "$HOST2 NICHT ok" - $BATCTL gw off - fi - + my_SN_IP=185.66.193.106 + other_SN_IP=185.66.193.105 +fi +#Auf 1 setzen um Lastverteilung 1/2 Monat einzuschalten +loadbalance=0 +#Default Supernode if loadbalance=0 +active_SN=$SN2 +day=$(date +%d) +if [ $loadbalance == 1 ] +then + if [ $day -gt 15 ] + then + active_SN=$SN1 + fi +fi +#Check other Supernode +if [ $iam != $active_SN ] +then + ping -q -c5 $other_SN_IP -I eth0 > /dev/null + if [ $? -eq 0 ] + then + echo "Active Supernode is running" + $BATCTL gw off + /usr/sbin/service bird6 stop + /usr/sbin/service bird stop + /usr/sbin/service tunneldigger stop + else + echo "First Supernode not running, activating backup Supernode" + $BATCTL gw server 100Mbit/100Mbit + /usr/sbin/service bird6 start + /usr/sbin/service bird start + /usr/sbin/service tunneldigger start + curl -X POST --data-urlencode 'payload={"text": "troisdorf5 nicht pingbar. troisdorf6 eingeschaltet", "channel": "#technik", "username": "troisdorf6", "icon_emoji": ":floppy_disk:"}' https://hooks.slack.com/services/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 + fi +else + # Check this Supernode + ping -q -c5 $my_SN_IP -I eth0 > /dev/null + if [ $? -eq 0 ] + then + echo "Supernode ok" + $BATCTL gw server 100Mbit/100Mbit + /usr/sbin/service bird6 start + /usr/sbin/service bird start + /usr/sbin/service tunneldigger start + else + echo "Supernode nicht pingbar" + $BATCTL gw off + /usr/sbin/service bird6 start + /usr/sbin/service bird start + /usr/sbin/service tunneldigger start + curl -X POST --data-urlencode 'payload={"text": "troisdorf6 nicht pingbar. services auf troisdorf6 neu gestartet", "channel": "#technik", "username": "troisdorf6", "icon_emoji": ":floppy_disk:"}' https://hooks.slack.com/services/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 + fi fi - From 9f3d61722a7a1972233ae14b0bd628646e3cb504 Mon Sep 17 00:00:00 2001 From: stebifan Date: Sun, 28 Feb 2016 11:47:51 +0100 Subject: [PATCH 2/3] Update keepalive.exit.sh.j2 --- files/keepalive.exit.sh.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/keepalive.exit.sh.j2 b/files/keepalive.exit.sh.j2 index 450bc9b..332a61a 100644 --- a/files/keepalive.exit.sh.j2 +++ b/files/keepalive.exit.sh.j2 @@ -41,7 +41,7 @@ then /usr/sbin/service bird6 start /usr/sbin/service bird start /usr/sbin/service tunneldigger start - curl -X POST --data-urlencode 'payload={"text": "troisdorf5 nicht pingbar. troisdorf6 eingeschaltet", "channel": "#technik", "username": "troisdorf6", "icon_emoji": ":floppy_disk:"}' https://hooks.slack.com/services/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 + curl -X POST --data-urlencode 'payload={"text": "troisdorf5 nicht pingbar. troisdorf6 eingeschaltet", "channel": "#technik", "username": "troisdorf6", "icon_emoji": ":floppy_disk:"}' https://hooks.slack.com/services/{{ slack_token }} fi else # Check this Supernode @@ -59,6 +59,6 @@ else /usr/sbin/service bird6 start /usr/sbin/service bird start /usr/sbin/service tunneldigger start - curl -X POST --data-urlencode 'payload={"text": "troisdorf6 nicht pingbar. services auf troisdorf6 neu gestartet", "channel": "#technik", "username": "troisdorf6", "icon_emoji": ":floppy_disk:"}' https://hooks.slack.com/services/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 + curl -X POST --data-urlencode 'payload={"text": "troisdorf6 nicht pingbar. services auf troisdorf6 neu gestartet", "channel": "#technik", "username": "troisdorf6", "icon_emoji": ":floppy_disk:"}' https://hooks.slack.com/services/{{ slack_token }} fi fi From 46b1933a7cb6c50ffb4fdd0cb07cbb757b046bf3 Mon Sep 17 00:00:00 2001 From: stebifan Date: Sun, 28 Feb 2016 11:55:38 +0100 Subject: [PATCH 3/3] Added radvd --- files/keepalive.exit.sh.j2 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/files/keepalive.exit.sh.j2 b/files/keepalive.exit.sh.j2 index 332a61a..abc1cc7 100644 --- a/files/keepalive.exit.sh.j2 +++ b/files/keepalive.exit.sh.j2 @@ -35,12 +35,14 @@ then /usr/sbin/service bird6 stop /usr/sbin/service bird stop /usr/sbin/service tunneldigger stop + /usr/sbin/service radvd stop else echo "First Supernode not running, activating backup Supernode" $BATCTL gw server 100Mbit/100Mbit /usr/sbin/service bird6 start /usr/sbin/service bird start /usr/sbin/service tunneldigger start + /usr/sbin/service radvd start curl -X POST --data-urlencode 'payload={"text": "troisdorf5 nicht pingbar. troisdorf6 eingeschaltet", "channel": "#technik", "username": "troisdorf6", "icon_emoji": ":floppy_disk:"}' https://hooks.slack.com/services/{{ slack_token }} fi else @@ -53,12 +55,14 @@ else /usr/sbin/service bird6 start /usr/sbin/service bird start /usr/sbin/service tunneldigger start + /usr/sbin/service radvd start else echo "Supernode nicht pingbar" $BATCTL gw off /usr/sbin/service bird6 start /usr/sbin/service bird start /usr/sbin/service tunneldigger start + /usr/sbin/service radvd start curl -X POST --data-urlencode 'payload={"text": "troisdorf6 nicht pingbar. services auf troisdorf6 neu gestartet", "channel": "#technik", "username": "troisdorf6", "icon_emoji": ":floppy_disk:"}' https://hooks.slack.com/services/{{ slack_token }} fi fi