Last active
February 8, 2018 08:21
-
-
Save mkoura/2a6b21e8049f878ebac1 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 | |
# PIA London PPTP | |
uuid="07067b81-d1d8-46cb-8b92-59341c69fe73" | |
# PIA NL PPTP | |
#uuid="f8ac9237-4865-4757-a78d-8d525dc846e5" | |
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