summaryrefslogtreecommitdiff
path: root/sh/vpn
diff options
context:
space:
mode:
Diffstat (limited to 'sh/vpn')
-rwxr-xr-xsh/vpn27
1 files changed, 27 insertions, 0 deletions
diff --git a/sh/vpn b/sh/vpn
new file mode 100755
index 0000000..dc855ed
--- /dev/null
+++ b/sh/vpn
@@ -0,0 +1,27 @@
+#!/bin/sh
+# toggle VPN
+
+down_not_mydefault () {
+ for v in wg_studio wg_ia wg_ka; do
+ nmcli connection down "$v"
+ done
+}
+
+# no toggle wg_mydefault, I want wg_mydefault to always on by default
+if ! [ "$1" ] || [ "$1" = mydefault ]; then
+ down_not_mydefault
+ nmcli connection up wg_mydefault
+ notify-send -u critical 'VPN disabled'
+ exit
+fi
+
+if nmcli -t --fields device,state device | grep -q "^wg_$1:connected$"; then
+ down_not_mydefault
+ nmcli connection up wg_mydefault
+ notify-send -u critical "$1 VPN disabled"
+else
+ down_not_mydefault
+ nmcli connection down wg_mydefault
+ nmcli connection up "wg_$1"
+ notify-send "$1 VPN enabled"
+fi