summaryrefslogtreecommitdiff
path: root/sh/vpn
diff options
context:
space:
mode:
authorXiao Pan <gky44px1999@gmail.com>2024-03-11 20:21:08 -0700
committerXiao Pan <gky44px1999@gmail.com>2024-03-11 20:21:08 -0700
commitda04f0c69f30bc355c2c07d8134795e09b8dbae4 (patch)
tree1bafcab4fde2b40f63298791ff320b019f612620 /sh/vpn
parent583adac015a32d496e88b3ef05af550fecb5841f (diff)
feat: new vip vpn scripts, move vip from public archive repo to fsh, vpn for toggle vpn
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