diff options
author | Xiao Pan <gky44px1999@gmail.com> | 2024-03-11 20:21:08 -0700 |
---|---|---|
committer | Xiao Pan <gky44px1999@gmail.com> | 2024-03-11 20:21:08 -0700 |
commit | da04f0c69f30bc355c2c07d8134795e09b8dbae4 (patch) | |
tree | 1bafcab4fde2b40f63298791ff320b019f612620 /sh/vpn | |
parent | 583adac015a32d496e88b3ef05af550fecb5841f (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-x | sh/vpn | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -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 |