[check-vpn-from-ovh] Cinquantieme version ...
... d'un script qui ne marche bien sur que quand on le teste a la main ... (Mais bon, ca devrait marcher cette fois, on y croit !) darcs-hash:20090617145935-ddb99-519f8906f3ce63552f49970183494ddad4eb252a.gz
This commit is contained in:
parent
1156c79c78
commit
b6f9b5570e
1 changed files with 11 additions and 3 deletions
|
@ -3,7 +3,13 @@
|
||||||
vpn_is_running () {
|
vpn_is_running () {
|
||||||
local pid_file
|
local pid_file
|
||||||
pid_file=/var/run/openvpn.$1.pid
|
pid_file=/var/run/openvpn.$1.pid
|
||||||
[[ ! -f $pid_file || ! -d /proc/$(< $pid_file) ]] && return 1 || return 0
|
if [ -f $pid_file ] && [ -d /proc/$(< $pid_file) ]
|
||||||
|
then if fping komaz.adm.crans.org &> /dev/null
|
||||||
|
then return 0
|
||||||
|
else return 1
|
||||||
|
fi
|
||||||
|
else return 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
vpn_start () {
|
vpn_start () {
|
||||||
|
@ -12,7 +18,8 @@ vpn_start () {
|
||||||
if ! [ -f /tmp/vpn_mail_sent ] || [ $((`date +%s` - `stat -c %X /tmp/vpn_mail_sent`)) -gt 300 ]
|
if ! [ -f /tmp/vpn_mail_sent ] || [ $((`date +%s` - `stat -c %X /tmp/vpn_mail_sent`)) -gt 300 ]
|
||||||
then
|
then
|
||||||
touch /tmp/vpn_mail_sent
|
touch /tmp/vpn_mail_sent
|
||||||
if /etc/init.d/openvpn start $1
|
# On utilise restart pour être sûr de ne pas avec de VPN qui traîne
|
||||||
|
if /etc/init.d/openvpn restart $1
|
||||||
then
|
then
|
||||||
echo "Lancement du vpn $(hostname)<->$1 reussi "'!'
|
echo "Lancement du vpn $(hostname)<->$1 reussi "'!'
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -21,7 +28,7 @@ vpn_start () {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
/etc/init.d/openvpn start $1 &> /dev/null
|
/etc/init.d/openvpn restart $1 &> /dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +40,7 @@ fi
|
||||||
if fping -q komaz.crans.org; then
|
if fping -q komaz.crans.org; then
|
||||||
# Si on peut atteindre komaz, on repasse par komaz
|
# Si on peut atteindre komaz, on repasse par komaz
|
||||||
if vpn_is_running freebox
|
if vpn_is_running freebox
|
||||||
|
then
|
||||||
if ! [ -f /tmp/vpn_mail_sent ] || [ $((`date +%s` - `stat -c %X /tmp/vpn_mail_sent`)) -gt 300 ]
|
if ! [ -f /tmp/vpn_mail_sent ] || [ $((`date +%s` - `stat -c %X /tmp/vpn_mail_sent`)) -gt 300 ]
|
||||||
then
|
then
|
||||||
/etc/init.d/openvpn stop freebox
|
/etc/init.d/openvpn stop freebox
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue