Skip to content

Instantly share code, notes, and snippets.

@vietdien2005
Last active June 21, 2022 00:03
Show Gist options
  • Save vietdien2005/3db969289ae1de1ad220393d28373ae4 to your computer and use it in GitHub Desktop.
Save vietdien2005/3db969289ae1de1ad220393d28373ae4 to your computer and use it in GitHub Desktop.
Script Auto Reconnect OpenVPN
#!/bin/bash
read -p "Type name config file vpn: " name_file
function getStatus () {
ifconfig | grep $1 && return 1
return 0
}
while [[ 1 ]]; do
getStatus tun0
if [[ $? == 0 ]]; then
echo "openvpn is not connected!"
echo "Reconnecting!"
#Replace your_sudo_password to your real user sudo password.
echo your_sudo_password | sudo -S openvpn --config /folder/openvpn/${name_file}.ovpn
sleep 10
fi
sleep 10
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment