-
-
Save cpoliver/44f73549ac72e12748c56ce8e89e615e to your computer and use it in GitHub Desktop.
script for starting/stopping vpn using Network Manager on Linux - can be used via keyboard shortcut
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/sh | |
# list of configured VPNs: `nmcli con show | grep vpn` | |
uuid="049b2d60-b816-4640-b33e-659920598c19" | |
active_uuid='' | |
for r in $(nmcli -t -f UUID,TYPE con show --active); do | |
ctype="${r##*:}" | |
if [ "$ctype" = 'vpn' ]; then | |
active_uuid="${r%%:*}" | |
nmcli con down uuid $active_uuid | |
break | |
fi | |
done | |
[ -z "$active_uuid" ] && nmcli con up uuid $uuid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment