
repasse sur la connexion principale quand celle-ci est a nouveau disponible. darcs-hash:20080304003109-af139-156c0ee1e39ea30359163396ba1db73d928b1387.gz
40 lines
888 B
Bash
Executable file
40 lines
888 B
Bash
Executable file
#!/bin/bash
|
|
|
|
vpn_is_running () {
|
|
local pid_file
|
|
pid_file=/var/run/openvpn.${pid_file}.pid
|
|
[[ ! -f $pid_file || ! -d /proc/$(< $pid_file) ]]
|
|
}
|
|
|
|
vpn_start () {
|
|
vpn_is_running $1 && exit 0
|
|
if /etc/init.d/openvpn start $1; then
|
|
echo "Lancement du vpn $(hostname)<->$1 reussi "'!'
|
|
exit 0
|
|
else
|
|
echo "Echec de lancement du vpn $(hostname)<->$1 "'!'
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
if vpn_is_running komaz; then
|
|
# Le vpn vers komaz est actif, tout va bien
|
|
exit 0
|
|
fi
|
|
|
|
if fping -q komaz.crans.org; then
|
|
# Si on peut atteindre komaz, on repasse par komaz
|
|
vpn_is_running freebox && /etc/init.d/openvpn stop freebox
|
|
vpn_start komaz
|
|
fi
|
|
|
|
if vpn_is_running freebox; then
|
|
# On ne peut pas atteindre komaz et on passe par la freebox, c'est
|
|
# normal
|
|
exit 0
|
|
fi
|
|
|
|
if fping -q freebox.crans.org; then
|
|
# On tente de passer par la freebox
|
|
vpn_start freebox
|
|
fi
|