modification du script de switch du vpn pour ovh
repasse sur la connexion principale quand celle-ci est a nouveau disponible. darcs-hash:20080304003109-af139-156c0ee1e39ea30359163396ba1db73d928b1387.gz
This commit is contained in:
parent
303c032b83
commit
81be789a47
1 changed files with 34 additions and 23 deletions
|
@ -1,29 +1,40 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
VPN_NAME=adm
|
vpn_is_running () {
|
||||||
PID_FILE=/var/run/openvpn.${VPN_NAME}.pid
|
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 [[ ! -f $PID_FILE || ! -d /proc/$(< $PID_FILE) ]]; then
|
|
||||||
if fping -q komaz.crans.org; then
|
if fping -q komaz.crans.org; then
|
||||||
ln -sf komaz.conf /etc/openvpn/${VPN_NAME}.conf
|
# Si on peut atteindre komaz, on repasse par komaz
|
||||||
if /etc/init.d/openvpn start ${VPN_NAME} > /dev/null; then
|
vpn_is_running freebox && /etc/init.d/openvpn stop freebox
|
||||||
echo 'Lancement du tunnel vers komaz reussi !'
|
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
|
exit 0
|
||||||
else
|
|
||||||
echo 'Echec du lancement du tunnel vers komaz !'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
elif fping -q freebox.crans.org; then
|
|
||||||
ln -sf freebox.conf /etc/openvpn/${VPN_NAME}.conf
|
|
||||||
if /etc/init.d/openvpn start ${VPN_NAME} > /dev/null; then
|
|
||||||
echo 'Lancement du tunnel vers freebox reussi !'
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
echo 'Echec du lancement du tunnel vers freebox !'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Impossible de determiner un point d'acces au CRANS "\!
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if fping -q freebox.crans.org; then
|
||||||
|
# On tente de passer par la freebox
|
||||||
|
vpn_start freebox
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue