2016-02-27 23:13:18 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#Variablen
|
|
|
|
iam=$(/bin/hostname)
|
2016-01-27 16:33:47 +00:00
|
|
|
BATCTL=/usr/local/sbin/batctl
|
2016-02-27 23:13:18 +00:00
|
|
|
SN1=troisdorf5
|
|
|
|
SN2=troisdorf6
|
|
|
|
if [ $iam == troisdorf5 ]
|
2016-01-27 16:33:47 +00:00
|
|
|
then
|
2016-02-27 23:13:18 +00:00
|
|
|
my_SN_IP=185.66.193.105
|
|
|
|
other_SN_IP=185.66.193.106
|
2016-01-26 23:15:32 +00:00
|
|
|
else
|
2016-02-27 23:13:18 +00:00
|
|
|
my_SN_IP=185.66.193.106
|
|
|
|
other_SN_IP=185.66.193.105
|
|
|
|
fi
|
|
|
|
#Auf 1 setzen um Lastverteilung 1/2 Monat einzuschalten
|
2016-02-28 23:30:15 +00:00
|
|
|
loadbalance=1
|
2016-02-27 23:13:18 +00:00
|
|
|
#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
|
2016-02-28 10:55:38 +00:00
|
|
|
/usr/sbin/service radvd stop
|
2016-02-27 23:13:18 +00:00
|
|
|
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
|
2016-02-28 10:55:38 +00:00
|
|
|
/usr/sbin/service radvd start
|
2016-02-28 11:47:49 +00:00
|
|
|
curl -X POST --data-urlencode 'payload={"text": "Aktiver Supernode nicht pingbar. {{ sn_hostname }} eingeschaltet", "channel": "#technik", "username": "{{ sn_hostname }}", "icon_emoji": ":warning:"}' https://hooks.slack.com/services/{{ slack_token }}
|
2016-02-27 23:13:18 +00:00
|
|
|
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
|
2016-02-28 10:55:38 +00:00
|
|
|
/usr/sbin/service radvd start
|
2016-02-27 23:13:18 +00:00
|
|
|
else
|
|
|
|
echo "Supernode nicht pingbar"
|
|
|
|
$BATCTL gw off
|
|
|
|
/usr/sbin/service bird6 start
|
|
|
|
/usr/sbin/service bird start
|
|
|
|
/usr/sbin/service tunneldigger start
|
2016-02-28 10:55:38 +00:00
|
|
|
/usr/sbin/service radvd start
|
2016-02-28 11:47:49 +00:00
|
|
|
curl -X POST --data-urlencode 'payload={"text": "{{ sn_hostname }} nicht pingbar. services auf {{ sn_hostname }} neu gestartet", "channel": "#technik", "username": "{{ sn_hostname }}", "icon_emoji": ":warning:"}' https://hooks.slack.com/services/{{ slack_token }}
|
2016-02-27 23:13:18 +00:00
|
|
|
fi
|
2016-01-26 23:15:32 +00:00
|
|
|
fi
|