Help! OpenVPN restart script not working

How to customize and extend your OpenVPN installation.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
cal
OpenVpn Newbie
Posts: 1
Joined: Sat Sep 12, 2015 10:34 pm

Help! OpenVPN restart script not working

Post by cal » Sat Sep 12, 2015 10:49 pm

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.

Post Reply