[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:
parent
afca20b0a7
commit
e48bff52a6
1 changed files with 21 additions and 6 deletions
|
@ -8,13 +8,21 @@ vpn_is_running () {
|
|||
|
||||
vpn_start () {
|
||||
vpn_is_running $1 && exit 0
|
||||
if /etc/init.d/openvpn start $1; then
|
||||
# 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
|
||||
/etc/init.d/openvpn start $1 &> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
if vpn_is_running komaz; then
|
||||
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue