Skip to content

Instantly share code, notes, and snippets.

@jonhkr
Forked from lowstz/auto-ovpn.sh
Last active August 29, 2015 14:03
Show Gist options
  • Save jonhkr/668dcf36969d4b3e00cc to your computer and use it in GitHub Desktop.
Save jonhkr/668dcf36969d4b3e00cc to your computer and use it in GitHub Desktop.
Openvpn auto reconnect
#!/bin/bash
### Thanks Xream's Work XD
#
# just run: $ sudo auto-ovpn.sh config.ovpn
#
ovpn=$1
getStatus () {
ifconfig | grep $1 && return 1
return 0
}
while true; do
getStatus tun0
if [ $? -eq 0 ]; then
echo "openvpn is not connected!"
echo "Reconnecting!"
openvpn --config ${ovpn}
sleep 6
fi
sleep 6
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment