вторник, 12 января 2016 г.

проверка и автоматическая установка туннеля VPNC

root@RPi2-mobile:~# crontab -l
# Edit this file to introduce tasks to be run by cron.
* * * * *  /usr/local/sbin/vpnc-keepalive 10.X.X.1 10.Y.Y.1 &

root@RPi2-mobile:~# cat /usr/local/sbin/vpnc-keepalive
#!/bin/sh
#
# Restart VPNC if both of the specified hosts on the command line are unavailable

if ! [ $(ping -q -c 1 ${1} 2>&1 | grep "1 packets received" | sed "s/.*\(1\) packets received.*/\1/") ] ||
   ! [ $(ping -q -c 1 ${2} 2>&1 | grep "1 packets received" | sed "s/.*\(1\) packets received.*/\1/") ]; then
    echo Not alive $1 or $2, restarting VPNC
    /etc/init.d/vpnc restart
else
echo Alive $1 or $2
fi

Комментариев нет:

Отправить комментарий