Router redundancy scripts

This commit is contained in:
Emmanuel BENOîT 2012-07-29 11:34:35 +02:00
parent 1cb97260ba
commit 7b0b2087b3
8 changed files with 356 additions and 0 deletions

15
routers/share/activate.sh Normal file
View file

@ -0,0 +1,15 @@
#!/bin/bash
#
# Example router activation script
#
# 1/ Remove default route through peer
# 2/ Take active router address
# 3/ Activate PPP link
# 4/ Wait for a few seconds
#
ip route del default via 192.168.1.1 dev eth0
ip addr add 192.168.1.1/24 dev eth0
ifup ppp0
sleep 10

View file

@ -0,0 +1,18 @@
#!/bin/bash
#
# Example router de-activation script
#
# 1/ Kill internet link
# 2/ Nuke them from orbit, it's the only way to be sure
# 3/ Release main router address
# 4/ Add default route through peer
#
ifdown --force ppp0
sleep 2
killall -9 pppd
sleep 2
ip addr del 192.168.1.1 dev eth0
ip route add default via 192.168.1.1 dev eth0

29
routers/share/pings Normal file
View file

@ -0,0 +1,29 @@
#!/bin/bash
try_ping()
{
export target="$1"
export prfile="$2"
export endfile=`mktemp`
(
if ping -c1 $target >/dev/null 2>&1; then
rm -f $prfile
fi
rm -f $endfile
) >/dev/null 2>&1 &
echo $endfile
}
wait_pings()
{
local ok=0
while [ "$ok" = "0" ]; do
sleep 1
ok=1
for file in $*; do
if [ -f "$file" ]; then
ok=0
fi
done
done
}