Created
April 16, 2020 07:22
-
-
Save filipsPL/33433a0938d153e46cb7b3c78d5b5f61 to your computer and use it in GitHub Desktop.
Bash check if a VPN connection is active, if not - connect!
This file contains hidden or 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 | |
vpnConnectionName="my vpn connection" | |
if nmcli c show --active | grep -q "$vpnConnectionName"; then | |
echo "$vpnConnectionName connection is up" | |
else | |
echo "$vpnConnectionName connection is down, let's connect" | |
nmcli con up id "$vpnConnectionName" | |
sleep 4s | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment