Keepalive exit
This commit is contained in:
parent
4768640a2d
commit
38c75df195
51
files/keepalive.exit.sh
Normal file
51
files/keepalive.exit.sh
Normal file
@ -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
|
||||
|
10
files/keepalive.exit.sh.j2
Normal file
10
files/keepalive.exit.sh.j2
Normal file
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user