Page 1 of 1

Help! OpenVPN restart script not working

Posted: Sat Sep 12, 2015 10:49 pm
by cal
The following script was posted on the openwrt forum https://forum.openwrt.org/viewtopic.php?id=31853
as a way of restarting OpenVPN.

The problem we're having is the ping is not going through when we run the script, but when we manually ping from the command line, the ping succeeds.
Anyone have ideas why this might happen?

Here's the script:

Code: Select all

#!/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
btw, we know about ping-restart and those other conf auto-restart options but we specifically want to use this script.