-
Notifications
You must be signed in to change notification settings - Fork 19
/
failover.sh
executable file
·35 lines (25 loc) · 1.48 KB
/
failover.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
STATE="default";
echo "DEFAULT" > /etc/network_state;
while true
do
RET=`ssh vagrant@pyth.group2.ingi -oStrictHostKeyChecking=no -i /etc/ssh_keys/PYTH 'echo "show protocols eBGP" | sudo birdc -s /tmp/PYTH.ctl 2> /dev/null'`
echo "$RET" | grep "Established" &> /dev/null
RES=$?;
if [ $RES == 0 ] && [ "$STATE" == "failover" ]; then
STATE="default";
echo "DEFAULT" > /etc/network_state;
nsupdate monitoring/nsupdate.default.txt;
ssh vagrant@pyth.group2.ingi -oStrictHostKeyChecking=no -i /etc/ssh_keys/PYTH 'echo "configure \"/etc/bird/bird6.conf\"" | sudo birdc -s /tmp/PYTH.ctl 2> /dev/null'
ssh vagrant@hall.group2.ingi -oStrictHostKeyChecking=no -i /etc/ssh_keys/HALL 'echo "configure \"/etc/bird/bird6.conf\"" | sudo birdc -s /tmp/HALL.ctl 2> /dev/null'
echo "New state of the network : DEFAULT";
elif [ $RES != 0 ] && [ "$STATE" == "default" ]; then
STATE="failover";
echo "FAILOVER" > /etc/network_state;
nsupdate monitoring/nsupdate.failover.txt;
ssh vagrant@pyth.group2.ingi -oStrictHostKeyChecking=no -i /etc/ssh_keys/PYTH 'echo "configure \"/etc/bird/bird6-failover.conf\"" | sudo birdc -s /tmp/PYTH.ctl 2> /dev/null'
ssh vagrant@hall.group2.ingi -oStrictHostKeyChecking=no -i /etc/ssh_keys/HALL 'echo "configure \"/etc/bird/bird6-failover.conf\"" | sudo birdc -s /tmp/HALL.ctl 2> /dev/null'
echo "New state of the network : FAILOVER";
fi
sleep 10
done