Skip to content

Instantly share code, notes, and snippets.

@andreasvirkus
Created July 26, 2015 21:18
Show Gist options
  • Save andreasvirkus/633926c1bef6294e089a to your computer and use it in GitHub Desktop.
Save andreasvirkus/633926c1bef6294e089a to your computer and use it in GitHub Desktop.
#!/bin/bash
# vpntog [vpn.name] [on/off/state] | (Dis)connect to the given VPN
if [ "$2" == 'on' ]; then
nmcli con up id $1
echo vpn @$1 > on
elif [ "$2" == 'off' ]; then
nmcli con down id $1
echo proxy @$1 > off
elif [ "$2" == 'state' ]; then
state=$(nmcli c show --active id "$1" | less)
echo Current state of vpn: $state
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment