Skip to content

Instantly share code, notes, and snippets.

@DerZyklop
Forked from aelveborn/vpn-status.sh
Created August 29, 2014 14:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DerZyklop/1e0b4dc8e63271820f86 to your computer and use it in GitHub Desktop.
Save DerZyklop/1e0b4dc8e63271820f86 to your computer and use it in GitHub Desktop.
Synology DSM 5 VPN reconnection script.Save file to /usr/openVPNreconnect then run chmod +x /usr/openVPNreconnect. Schedule by following http://forum.synology.com/enu/viewtopic.php?f=241&t=65444
# Replace o1234567890 with your OpenVPN id. To get your id, start the VPN and run ps|grep client_o
# Replace YOUR_VPN_NAME with the name of your VPN profile in DSM 5 admin panel.
if echo `ifconfig tun0` | grep -q "00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00"
then
echo "VPN is running"
else
echo conf_id=o1234567890 > /usr/syno/etc/synovpnclient/vpnc_connecting
echo conf_name=YOUR_VPN_NAME >> /usr/syno/etc/synovpnclient/vpnc_connecting
echo proto=openvpn >> /usr/syno/etc/synovpnclient/vpnc_connecting
synovpnc reconnect --protocol=openvpn --name=YOUR_VPN_NAME
fi
exit 0
@DerZyklop
Copy link
Author

The conf_id can be found in /usr/syno/etc/synovpnclient/openvpn/ovpnclient.conf.

@DerZyklop
Copy link
Author

A cronjob can be installed like this.

// backup of current cronjob
cp /etc/crontab /root/crontab.bak

Then open /etc/crontab and add a new line for a new job

*/5     *       *       *       *       root    /usr/openVPNreconnect

@DerZyklop
Copy link
Author

Then you'll have to restart your cron deamon by:

/usr/syno/sbin/synoservicectl --restart crond

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment