Last active
March 25, 2023 14:21
-
-
Save mjnaderi/d4b50c76e0bb5fc0d066 to your computer and use it in GitHub Desktop.
UpVPN (reconnect vpn when disconnected)
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 | |
# Usage: | |
# ./upvpn.sh "VPN Connection Name" | |
VPN="$1" | |
trap "exit 0" SIGINT SIGTERM | |
while true; do | |
if ! nmcli con show --active | grep -q "$VPN"; then | |
echo "[`date`] Disconnected. Trying to reconnect..." | |
nmcli -p con up id "$VPN" | |
sleep 5 | |
fi | |
sleep 0.5 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment