Skip to content

Instantly share code, notes, and snippets.

@messi89
Created August 6, 2020 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save messi89/e79cbfd452c670694b0a40fd43f7949e to your computer and use it in GitHub Desktop.
Save messi89/e79cbfd452c670694b0a40fd43f7949e to your computer and use it in GitHub Desktop.
OpenVPN connect script
#!/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