Created
August 6, 2020 08:31
-
-
Save messi89/e79cbfd452c670694b0a40fd43f7949e to your computer and use it in GitHub Desktop.
OpenVPN connect script
This file contains 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
#!/bin/bash | |
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin | |
function getStatus () { | |
ifconfig | grep $1 && return 1 | |
return 0 | |
} | |
while [[ 1 ]]; do | |
getStatus tun0 | |
if [[ $? == 0 ]]; then | |
echo "openvpn is not connected!" | |
echo "Reconnecting!" | |
echo your_root_password | sudo -S openvpn --config /root/client.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