diff --git a/files/keepalive.exit.sh.j2 b/files/keepalive.exit.sh.j2 index 0c2c8ba..91eeda4 100644 --- a/files/keepalive.exit.sh.j2 +++ b/files/keepalive.exit.sh.j2 @@ -1,4 +1,5 @@ #!/bin/bash +supernode_off while [ true ] ; do online=$(/bin/cat /etc/supernode-status/supernode.status) mode=$(/bin/cat /etc/supernode-status/supernode.mode) @@ -7,17 +8,31 @@ while [ true ] ; do BATCTL=/usr/local/sbin/batctl #### Settings #### # Names of the 2 Supernodes # - SN1=troisdorf5 - SN2=troisdorf6 loadbalance=$(cat /etc/supernode-status/loadbalancing.mode) if [ $iam = "troisdorf5" ]; then my_SN_IP=185.66.193.105 other_SN_IP=185.66.193.106 meship=10.188.255.5 - else + SN1=troisdorf5 + SN2=troisdorf6 + elif [ $iam = "troisdorf6" ]; then my_SN_IP=185.66.193.106 other_SN_IP=185.66.193.105 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 if [ $loadbalance = "1" ] && [ $mode != "0" ]; then if [ $day -gt 15 ]; then @@ -78,12 +93,12 @@ while [ true ] ; do if [ $? -eq 0 ] 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 supernode_off else 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 fi else @@ -93,12 +108,12 @@ while [ true ] ; do if [ $? -eq 0 ] 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 supernode_on else 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