Skip to content

Instantly share code, notes, and snippets.

@lindeskar
Forked from aelveborn/vpn-status.sh
Last active January 21, 2017 10:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lindeskar/a5cffe6064d547e9b9483ffe9e322310 to your computer and use it in GitHub Desktop.
Save lindeskar/a5cffe6064d547e9b9483ffe9e322310 to your computer and use it in GitHub Desktop.
My edits of the Synology VPN reconnection script by aelveborn.
#!/bin/sh
# Replace o1234567890 with your VPN id. To get your id, start the VPN and run: sudo ps aux | grep client_o
# Replace home with the name of your VPN profile in DSM admin panel.
vpnId="o1234567890"
vpnName="home"
vpnProtocol="openvpn"
# You should not need to change the following variables
vpncFile="/usr/syno/etc/synovpnclient/vpnc_connecting"
vpncBin="/usr/syno/bin/synovpnc"
reconnectVPNc () {
echo conf_id=$vpnId > $vpncFile
echo conf_name=$vpnName >> $vpncFile
echo proto=$vpnProtocol >> $vpncFile
$vpncBin reconnect --protocol=$vpnProtocol --name=$vpnName
}
if echo `ifconfig tun0` | grep -q "00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00"
then
logger -p 0 -s "VPN is up."
else
logger -p 0 -s "VPN is down! Trying to reconnect."
reconnectVPNc
fi
if echo `netstat -rn` | grep -q "tun0"
then
logger -p 0 -s "VPN route is ok."
else
logger -p 0 -s "VPN route not found! Reconnecting."
$vpncBin kill_client --protocol=$vpnProtocol --name=$vpnName
reconnectVPNc
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment