Project:VPN:vpn autorestart script
From Neutrinet
in /etc
rc.local
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. cd /etc python n2openvpnd & exit 0
n2openvpnd
#!python
import urllib2, time, subprocess
def connection_on():
try:
response=urllib2.urlopen('http://myyunohosturl.whatever',timeout=1) # CHANGE THIS URL <<<
return True
except urllib2.URLError as err: pass
return False
while True:
if connection_on() :
print('connected')
time.sleep(30)
else :
print('not connected')
# subprocess.call('killall openvpn', shell=True)
subprocess.call('/etc/startopenvpn.sh', shell=True)
time.sleep(30)
startopenvpn.sh
#!/bin/sh killall openvpn cd /root/neutrinet-vpn openvpn neutrinet.ovpn &