diff --git a/files/keepalive.exit.sh b/files/keepalive.exit.sh new file mode 100644 index 0000000..19c28dc --- /dev/null +++ b/files/keepalive.exit.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# Version 1.6 +# Parameter setzen +GATEWAY1ext=185.66.193.105 +GATEWAY2ext=185.66.193.106 +GATEWAY1=10.188.255.5 +GATEWAY2=10.188.255.6 +GATEWAY1v6=2a03:2260:121::255:5 +GATEWAY2v6=2a03:2260:121::255:6 +IP=/sbin/ip +PING=/bin/ping +BATCTL=/usr/local/sbin/batctl + +#if [ "hostname = troisdorf1 | troisdorf2" ] +if [ $(hostname) = "troisdorf1" ] || [ $(hostname) = "troisdorf2" ] + then + DEFAULT_GATEWAY=$GATEWAY1 + DEFAULT_GATEWAYext=$GATEWAY1ext + FALLBACK_GATEWAY=$GATEWAY2 + FALLBACK_GATEWAYext=$GATEWAY2ext + DEFAULT_GATEWAYv6=$GATEWAY1v6 + FALLBACK_GATEWAYv6=$GATEWAY2v6 + else + DEFAULT_GATEWAY=$GATEWAY2 + DEFAULT_GATEWAYext=$GATEWAY2ext + FALLBACK_GATEWAY=$GATEWAY1 + FALLBACK_GATEWAYext=$GATEWAY1ext + DEFAULT_GATEWAYv6=$GATEWAY2v6 + FALLBACK_GATEWAYv6=$GATEWAY1v6 + +fi + +if $PING -c 1 $DEFAULT_GATEWAYext + then + $IP route replace default via $DEFAULT_GATEWAY table 42 + $IP -6 route replace default via $DEFAULT_GATEWAYv6 table 42 + $BATCTL gw server 100Mbit/100Mbit + echo "Gateway erreichbar" + else + if $PING -c 1 $FALLBACK_GATEWAYext + then + $IP route replace default via $FALLBACK_GATEWAY table 42 + $IP -6 route replace default via $FALLBACK_GATEWAYv6 table 42 + $BATCTL gw server 80Mbit/80Mbit + echo "Nun FALLBACK_GATEWAY" + else + $BATCTL gw off + #Kein Gateway erreichbar, batctl gw off + fi +fi + diff --git a/files/keepalive.exit.sh.j2 b/files/keepalive.exit.sh.j2 new file mode 100644 index 0000000..6a4443c --- /dev/null +++ b/files/keepalive.exit.sh.j2 @@ -0,0 +1,10 @@ +#!/bin/bash + +ping -q -I {{ sn_ffrl_IPv4 }} 8.8.8.8 -c 4 -i 1 -W 5 >/dev/null 2>&1 + +if test $? -eq 0; then + /usr/local/sbin/batctl gw server 100Mbit/100Mbit +else + /usr/local/sbin/batctl gw off +fi + diff --git a/files/l2tp_backbone.sh.exit.j2 b/files/l2tp_backbone.sh.exit.j2 index 1e3f53d..f9bca4c 100644 --- a/files/l2tp_backbone.sh.exit.j2 +++ b/files/l2tp_backbone.sh.exit.j2 @@ -54,6 +54,8 @@ $ip -6 addr add $communitynetworkv6$octet3rd:${localserver#$communityname}/64 de $alfred -i bat0 > /dev/null 2>&1 & /bin/sleep 15 $batadv -i bat0 -s > /dev/null 2>&1 & -/usr/sbin/service bind9 restart +/bin/systemctl restart isc-dhcp-server +/bin/systemctl restart bind9 #/usr/local/sbin/batctl gw client 3 /usr/local/sbin/batctl gw server 100Mbit/100Mbit + diff --git a/files/sn_startup.exit.sh.j2 b/files/sn_startup.exit.sh.j2 index 7e40342..ba45058 100644 --- a/files/sn_startup.exit.sh.j2 +++ b/files/sn_startup.exit.sh.j2 @@ -53,24 +53,12 @@ done sleep 5 -# stop tunneldigger -/bin/systemctl disable tunneldigger -/bin/systemctl stop tunneldigger - # restart bird /bin/systemctl start bird /bin/systemctl start bird6 /bin/systemctl enable bird /bin/systemctl enable bird6 -# stop radvd -/bin/systemctl disable radvd -/bin/systemctl stop radvd - -# restart DHCP -/bin/systemctl disable isc-dhcp-server -/bin/systemctl stop isc-dhcp-server - # Start tunneldigger /bin/systemctl restart tunneldigger /bin/systemctl enable tunneldigger @@ -79,8 +67,4 @@ sleep 5 /bin/systemctl restart radvd /bin/systemctl enable radvd -# restart DHCP -/bin/systemctl restart isc-dhcp-server -/bin/systemctl enable isc-dhcp-server - exit 0 diff --git a/install.sn.yml b/install.sn.yml index c846a79..eba6c99 100644 --- a/install.sn.yml +++ b/install.sn.yml @@ -196,7 +196,13 @@ copy: src=./files/{{ item }} dest=/opt/freifunk owner=root group=root mode=0500 with_items: check_gw_script register: check_gw -# when: sn_exit is undefined + when: sn_exit is undefined + + - name: Check gateway / keepalive script + template: src=./files/keepalive.exit.sh.j2 dest=/opt/freifunk/keepalive.sh owner=root group=root mode=0500 + register: check_gw + when: sn_exit is defined + - name: Add cron job with check gateway script cron: name=check_gw job="/opt/freifunk/keepalive.sh > /dev/null 2>&1" user="root" when: check_gw.changed