[check-vpn-from-ovh] On n'envoie un mail que toutes les 5 minutes

darcs-hash:20090327095237-ddb99-d2a3cded891f77c2938e55a9a253ff5aa425a646.gz
This commit is contained in:
Michel Blockelet 2009-03-27 10:52:37 +01:00
parent afca20b0a7
commit e48bff52a6

View file

@ -8,12 +8,20 @@ vpn_is_running () {
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
# On n'envoie un mail que toutes les 5 minutes
if ! [ -f /tmp/vpn_mail_sent ] || [ $((`date +%s` - `stat -c %X /tmp/vpn_mail_sent`)) -gt 300 ]
then
touch /tmp/vpn_mail_sent
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
else
echo "Echec de lancement du vpn $(hostname)<->$1 "'!'
exit 1
/etc/init.d/openvpn start $1 &> /dev/null
fi
}
@ -24,7 +32,14 @@ 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
if vpn_is_running freebox
if ! [ -f /tmp/vpn_mail_sent ] || [ $((`date +%s` - `stat -c %X /tmp/vpn_mail_sent`)) -gt 300 ]
then
/etc/init.d/openvpn stop freebox
else
/etc/init.d/openvpn stop freebox &> /dev/null
fi
fi
vpn_start komaz
fi