Skip to content

Instantly share code, notes, and snippets.

@meska
Created December 5, 2015 14:14
Show Gist options
  • Save meska/082e1ca9cb7717b2283e to your computer and use it in GitHub Desktop.
Save meska/082e1ca9cb7717b2283e to your computer and use it in GitHub Desktop.
Synology openvpn check and restart script
#!/bin/sh
# synology openvpn restart script
# get config and name here:
# cat /usr/syno/etc/synovpnclient/openvpn/ovpnclient.conf
if [[ `ifconfig | grep tun0 | wc -l` -eq 0 ]]; then
echo "Offline, restart"
echo conf_id=oXXXXXXXX > /usr/syno/etc/synovpnclient/vpnc_connecting
echo conf_name=XXXXXXXXXX >> /usr/syno/etc/synovpnclient/vpnc_connecting
echo proto=openvpn >> /usr/syno/etc/synovpnclient/vpnc_connecting
synovpnc reconnect --protocol=openvpn --name=XXXXXXXXXX
else
wget -q --tries=1 --timeout=10 --spider http://google.com
if [[ $? -eq 0 ]]; then
echo "Online"
else
echo "Hung, restart"
synovpnc kill_client
echo conf_id=oXXXXXXXXXX > /usr/syno/etc/synovpnclient/vpnc_connecting
echo conf_name=XXXXXXXXXX >> /usr/syno/etc/synovpnclient/vpnc_connecting
echo proto=openvpn >> /usr/syno/etc/synovpnclient/vpnc_connecting
synovpnc reconnect --protocol=openvpn --name=XXXXXXXXXX
fi
fi
@syrabo
Copy link

syrabo commented Dec 20, 2022

Thanks! Works with DSM 7.1

@meska
Copy link
Author

meska commented Dec 20, 2022

Thanks! Works with DSM 7.1
You are welcome ! I forgot about this gist 👍

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