Update keepalive.exit.sh.j2
This commit is contained in:
parent
4888848682
commit
299acefb3e
@ -1,29 +1,64 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
#
|
#Variablen
|
||||||
# -q quiet
|
iam=$(/bin/hostname)
|
||||||
# -c nb of pings
|
|
||||||
|
|
||||||
HOST1=8.8.8.8
|
|
||||||
HOST2=8.8.4.4
|
|
||||||
BATCTL=/usr/local/sbin/batctl
|
BATCTL=/usr/local/sbin/batctl
|
||||||
|
SN1=troisdorf5
|
||||||
ping -q -c5 $HOST1 > /dev/null
|
SN2=troisdorf6
|
||||||
if [ $? -eq 0 ]
|
if [ $iam == troisdorf5 ]
|
||||||
then
|
then
|
||||||
echo "ok"
|
my_SN_IP=185.66.193.105
|
||||||
$BATCTL gw server 100Mbit/100Mbit
|
other_SN_IP=185.66.193.106
|
||||||
else
|
else
|
||||||
|
my_SN_IP=185.66.193.106
|
||||||
echo "$HOST1 NICHT ok"
|
other_SN_IP=185.66.193.105
|
||||||
ping -q -c5 $HOST2 > /dev/null
|
fi
|
||||||
if [ $? -eq 0 ]
|
#Auf 1 setzen um Lastverteilung 1/2 Monat einzuschalten
|
||||||
then
|
loadbalance=0
|
||||||
echo "$HOST2 ok"
|
#Default Supernode if loadbalance=0
|
||||||
$BATCTL gw server 100Mbit/100Mbit
|
active_SN=$SN2
|
||||||
else
|
day=$(date +%d)
|
||||||
echo "$HOST2 NICHT ok"
|
if [ $loadbalance == 1 ]
|
||||||
$BATCTL gw off
|
then
|
||||||
fi
|
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
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user