Keepalive Changes for new SN

This commit is contained in:
Stefan Hoffmann 2016-05-13 23:40:55 +02:00
parent c594daa5ba
commit 1835cf4e6c

View File

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
supernode_off
while [ true ] ; do while [ true ] ; do
online=$(/bin/cat /etc/supernode-status/supernode.status) online=$(/bin/cat /etc/supernode-status/supernode.status)
mode=$(/bin/cat /etc/supernode-status/supernode.mode) mode=$(/bin/cat /etc/supernode-status/supernode.mode)
@ -7,17 +8,31 @@ while [ true ] ; do
BATCTL=/usr/local/sbin/batctl BATCTL=/usr/local/sbin/batctl
#### Settings #### #### Settings ####
# Names of the 2 Supernodes # # Names of the 2 Supernodes #
SN1=troisdorf5
SN2=troisdorf6
loadbalance=$(cat /etc/supernode-status/loadbalancing.mode) loadbalance=$(cat /etc/supernode-status/loadbalancing.mode)
if [ $iam = "troisdorf5" ]; then if [ $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.255.5
else SN1=troisdorf5
SN2=troisdorf6
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.105
meship=10.188.255.6 meship=10.188.255.6
SN1=troisdorf5
SN2=troisdorf6
elif [ $iam = "troisdorf1" ]; then
my_SN_IP=185.66.193.101
other_SN_IP=185.66.193.102
meship=10.188.255.1
SN1=troisdorf1
SN2=troisdorf2
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 [ $loadbalance = "1" ] && [ $mode != "0" ]; then
if [ $day -gt 15 ]; then if [ $day -gt 15 ]; then
@ -78,12 +93,12 @@ while [ true ] ; do
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
if [ $online ==1 ] || [ $online = 2 ]; then if [ $online ==1 ] || [ $online = 2 ]; then
curl -X POST --data-urlencode 'payload={"text": "Aktiver Supernode wieder online. Ich habe mich wieder ausgeschaltet", "channel": "#technik", "username": "$iam", "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_on
curl -X POST --data-urlencode 'payload={"text": "Aktiver Supernode offline. Ich habe mich eingeschaltet", "channel": "#technik", "username": "$iam", "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 sleep 300
fi fi
else else
@ -93,12 +108,12 @@ while [ true ] ; do
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
if [ $online = 0 ] || [ $online = 3 ]; then if [ $online = 0 ] || [ $online = 3 ]; then
curl -X POST --data-urlencode 'payload={"text": "Ich bin jetzt Supernode!", "channel": "#technik", "username": "$iam", "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
supernode_on supernode_on
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": "$iam", "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 fi