Last active
June 21, 2022 00:03
-
-
Save vietdien2005/3db969289ae1de1ad220393d28373ae4 to your computer and use it in GitHub Desktop.
Script Auto Reconnect OpenVPN
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 | |
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