From da04f0c69f30bc355c2c07d8134795e09b8dbae4 Mon Sep 17 00:00:00 2001 From: Xiao Pan <gky44px1999@gmail.com> Date: Mon, 11 Mar 2024 20:21:08 -0700 Subject: feat: new vip vpn scripts, move vip from public archive repo to fsh, vpn for toggle vpn --- sh/vpn | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 sh/vpn (limited to 'sh/vpn') 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 -- cgit v1.2.3-70-g09d2