Keepalive for new-new-net
This commit is contained in:
parent
ed9222a3b4
commit
0c1c3a3620
@ -6,44 +6,33 @@ while [ true ] ; do
|
|||||||
iam=$(/bin/hostname)
|
iam=$(/bin/hostname)
|
||||||
day=$(date +%d)
|
day=$(date +%d)
|
||||||
BATCTL=/usr/local/sbin/batctl
|
BATCTL=/usr/local/sbin/batctl
|
||||||
active_SN=$iam
|
|
||||||
#### Settings ####
|
#### Settings ####
|
||||||
# Names of the 2 Supernodes #
|
# Names of the 2 Supernodes #
|
||||||
loadbalance=$(cat /etc/supernode-status/loadbalancing.mode)
|
if [ $iam = "troisdorf4" ]; then
|
||||||
if [ $iam = "troisdorf5" ]; then
|
my_SN_IP=185.66.193.104
|
||||||
|
other_SN_IP=185.66.193.105
|
||||||
|
meship=10.188.0.4
|
||||||
|
SN1=troisdorf4
|
||||||
|
SN2=troisdorf5
|
||||||
|
elif [ $iam = "troisdorf5" ]; then
|
||||||
my_SN_IP=185.66.193.105
|
my_SN_IP=185.66.193.105
|
||||||
other_SN_IP=185.66.193.106
|
other_SN_IP=185.66.193.106
|
||||||
meship=10.188.255.5
|
meship=10.188.32.5
|
||||||
SN1=troisdorf5
|
SN1=troisdorf5
|
||||||
SN2=troisdorf6
|
SN2=troisdorf6
|
||||||
elif [ $iam = "troisdorf6" ]; then
|
elif [ $iam = "troisdorf6" ]; then
|
||||||
my_SN_IP=185.66.193.106
|
my_SN_IP=185.66.193.106
|
||||||
other_SN_IP=185.66.193.105
|
other_SN_IP=185.66.193.107
|
||||||
meship=10.188.255.6
|
meship=10.188.64.6
|
||||||
SN1=troisdorf5
|
SN1=troisdorf6
|
||||||
SN2=troisdorf6
|
SN2=troisdorf7
|
||||||
elif [ $iam = "troisdorf1" ]; then
|
elif [ $iam = "troisdorf7" ]; then
|
||||||
my_SN_IP=185.66.193.101
|
my_SN_IP=185.66.193.107
|
||||||
other_SN_IP=185.66.193.102
|
other_SN_IP=185.66.193.104
|
||||||
meship=10.188.255.1
|
meship=10.188.92.7
|
||||||
SN1=troisdorf1
|
SN1=troisdorf7
|
||||||
SN2=troisdorf2
|
SN2=troisdorf4
|
||||||
elif [ $iam = "troisdorf2" ]; then
|
|
||||||
my_SN_IP=185.66.193.102
|
|
||||||
other_SN_IP=185.66.193.101
|
|
||||||
meship=10.188.255.2
|
|
||||||
SN1=troisdorf1
|
|
||||||
SN2=troisdorf2
|
|
||||||
fi
|
fi
|
||||||
if [ $loadbalance = "1" ] && [ $mode != "0" ]; then
|
|
||||||
if [ $day -gt 15 ]; then
|
|
||||||
active_SN=$SN1
|
|
||||||
else
|
|
||||||
active_SN=$SN2
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# functions #
|
# functions #
|
||||||
# Supernode off #
|
# Supernode off #
|
||||||
@ -54,11 +43,7 @@ while [ true ] ; do
|
|||||||
/usr/sbin/service tunneldigger stop
|
/usr/sbin/service tunneldigger stop
|
||||||
/usr/sbin/service radvd stop
|
/usr/sbin/service radvd stop
|
||||||
/usr/sbin/service isc-dhcp-server stop
|
/usr/sbin/service isc-dhcp-server stop
|
||||||
if [ $loadbalance == 1 ] && [ $mode != 0 ]; then
|
|
||||||
echo 3 > /etc/supernode-status/supernode.status
|
|
||||||
else
|
|
||||||
echo 0 > /etc/supernode-status/supernode.status
|
echo 0 > /etc/supernode-status/supernode.status
|
||||||
fi
|
|
||||||
echo "collectd.gateways.$iam.sn-status $online `date +%s`" | nc -q 0 10.188.1.27 2003
|
echo "collectd.gateways.$iam.sn-status $online `date +%s`" | nc -q 0 10.188.1.27 2003
|
||||||
}
|
}
|
||||||
# Supernode on #
|
# Supernode on #
|
||||||
@ -67,13 +52,22 @@ while [ true ] ; do
|
|||||||
/usr/sbin/service bird6 start
|
/usr/sbin/service bird6 start
|
||||||
/usr/sbin/service bird start
|
/usr/sbin/service bird start
|
||||||
/usr/sbin/service tunneldigger start
|
/usr/sbin/service tunneldigger start
|
||||||
|
/usr/sbin/service tunneldigger-backup stop
|
||||||
/usr/sbin/service radvd start
|
/usr/sbin/service radvd start
|
||||||
/usr/sbin/service isc-dhcp-server start
|
/usr/sbin/service isc-dhcp-server start
|
||||||
if [ $loadbalance == 1 ]; then
|
|
||||||
echo 1 > /etc/supernode-status/supernode.status
|
echo 1 > /etc/supernode-status/supernode.status
|
||||||
else
|
echo "collectd.gateways.$iam.sn-status $online `date +%s`" | nc -q 0 10.188.1.27 2003
|
||||||
|
}
|
||||||
|
# Supernode Backup Mode
|
||||||
|
supernode_backup () {
|
||||||
|
$BATCTL gw server 100Mbit/100Mbit
|
||||||
|
/usr/sbin/service bird6 start
|
||||||
|
/usr/sbin/service bird start
|
||||||
|
/usr/sbin/service tunneldigger start
|
||||||
|
/usr/sbin/service tunneldigger-backup start
|
||||||
|
/usr/sbin/service radvd start
|
||||||
|
/usr/sbin/service isc-dhcp-server start
|
||||||
echo 2 > /etc/supernode-status/supernode.status
|
echo 2 > /etc/supernode-status/supernode.status
|
||||||
fi
|
|
||||||
echo "collectd.gateways.$iam.sn-status $online `date +%s`" | nc -q 0 10.188.1.27 2003
|
echo "collectd.gateways.$iam.sn-status $online `date +%s`" | nc -q 0 10.188.1.27 2003
|
||||||
}
|
}
|
||||||
# Restart Services #
|
# Restart Services #
|
||||||
@ -88,36 +82,35 @@ while [ true ] ; do
|
|||||||
echo "collectd.gateways.$iam.sn-status $online `date +%s`" | nc -q 0 10.188.1.27 2003
|
echo "collectd.gateways.$iam.sn-status $online `date +%s`" | nc -q 0 10.188.1.27 2003
|
||||||
}
|
}
|
||||||
#Check other Supernode
|
#Check other Supernode
|
||||||
if [ $iam != $active_SN ];
|
nc -zvu $other_SN_IP 53842
|
||||||
then
|
|
||||||
ping -q -c5 $other_SN_IP -I eth0 > /dev/null
|
|
||||||
if [ $? -eq 0 ]
|
if [ $? -eq 0 ]
|
||||||
then
|
then
|
||||||
if [ $online ==1 ] || [ $online = 2 ]; then
|
if [ $online = 2 ]; then
|
||||||
curl -X POST --data-urlencode 'payload={"text": "Aktiver Supernode wieder online. Ich habe mich wieder ausgeschaltet", "channel": "#technik", "username": "{{ sn_hostname }}", "icon_emoji": ":white_check_mark:"}' https://hooks.slack.com/services/{{ slack_token }}
|
curl -X POST --data-urlencode 'payload={"text": "Aktiver Supernode wieder online. Ich habe mich wieder ausgeschaltet", "channel": "#technik", "username": "{{ sn_hostname }}", "icon_emoji": ":white_check_mark:"}' https://hooks.slack.com/services/{{ slack_token }}
|
||||||
fi
|
fi
|
||||||
supernode_off
|
supernode_off
|
||||||
else
|
else
|
||||||
supernode_on
|
supernode_backup
|
||||||
curl -X POST --data-urlencode 'payload={"text": "Aktiver Supernode offline. Ich habe mich eingeschaltet", "channel": "#technik", "username": "{{ sn_hostname }}", "icon_emoji": ":warning:"}' https://hooks.slack.com/services/{{ slack_token }}
|
curl -X POST --data-urlencode 'payload={"text": "Aktiver Supernode offline. Ich habe mich eingeschaltet", "channel": "#technik", "username": "{{ sn_hostname }}", "icon_emoji": ":warning:"}' https://hooks.slack.com/services/{{ slack_token }}
|
||||||
sleep 300
|
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
# Check this Supernode
|
# Check this Supernode
|
||||||
if [ $mode != "0" ]; then
|
if [ $mode != "0" ]; then
|
||||||
ping -q -c5 $my_SN_IP -I eth0 > /dev/null
|
ping -q -c5 $my_SN_IP -I eth0 > /dev/null
|
||||||
if [ $? -eq 0 ]
|
if [ $? -eq 0 ]
|
||||||
then
|
then
|
||||||
if [ $online = 0 ] || [ $online = 3 ]; then
|
if [ $online = 0 ]; then
|
||||||
curl -X POST --data-urlencode 'payload={"text": "Ich bin jetzt Supernode!", "channel": "#technik", "username": "{{ sn_hostname }}", "icon_emoji": ":white_check_mark:"}' https://hooks.slack.com/services/{{ slack_token }}
|
curl -X POST --data-urlencode 'payload={"text": "Ich bin jetzt Supernode!", "channel": "#technik", "username": "{{ sn_hostname }}", "icon_emoji": ":white_check_mark:"}' https://hooks.slack.com/services/{{ slack_token }}
|
||||||
fi
|
fi
|
||||||
|
if [ mode == 1 ]; then
|
||||||
supernode_on
|
supernode_on
|
||||||
|
else
|
||||||
|
supernode_backup
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
supernode_fail
|
supernode_fail
|
||||||
curl -X POST --data-urlencode 'payload={"text": "Ich konnte mich selbst nicht anpingen. Ich versuche mal die Services neu zu starten", "channel": "#technik", "username": "{{ sn_hostname }}", "icon_emoji": ":warning:"}' https://hooks.slack.com/services/{{ slack_token }}
|
curl -X POST --data-urlencode 'payload={"text": "Ich konnte mich selbst nicht anpingen. Ich versuche mal die Services neu zu starten", "channel": "#technik", "username": "{{ sn_hostname }}", "icon_emoji": ":warning:"}' https://hooks.slack.com/services/{{ slack_token }}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
# Supernode off
|
# Supernode off
|
||||||
if [ $mode = "0" ]; then
|
if [ $mode = "0" ]; then
|
||||||
supernode_off
|
supernode_off
|
||||||
|
Loading…
Reference in New Issue
Block a user