Created
October 13, 2014 09:11
-
-
Save jonas8/2db6eb21393aa2baba5e to your computer and use it in GitHub Desktop.
google glass auto openvpn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/system/bin/sh | |
getStatus () { | |
ps | grep openvpn && return 1 | |
netcfg | grep $1 && return 1 | |
return 0 | |
} | |
getWlanConnectStatus() | |
{ | |
ifconfig wlan0 | egrep '([0-9]{1,3}\.){3}[0-9]{1,3}' && return 1 | |
return 0 | |
} | |
while [[ 1 ]]; do | |
getWlanConnectStatus | |
if [[ $? == 1 ]]; then | |
getStatus tun0 | |
if [[ $? == 0 ]]; then | |
echo "openvpn is not connected!" | |
echo "Reconnecting!" | |
openvpn /sdcard/openvpn/my_expressvpn_los_angeles_udp.ovpn | |
sleep 6 | |
fi | |
else | |
echo 'network disconnected, kill openvpn' | |
killall openvpn | |
sleep 6 | |
fi | |
sleep 3 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment