summaryrefslogtreecommitdiff
path: root/sh/vpn
diff options
context:
space:
mode:
Diffstat (limited to 'sh/vpn')
-rwxr-xr-xsh/vpn22
1 files changed, 11 insertions, 11 deletions
diff --git a/sh/vpn b/sh/vpn
index 7898e57..8be4657 100755
--- a/sh/vpn
+++ b/sh/vpn
@@ -1,9 +1,9 @@
#!/bin/sh
# toggle VPN
-down_not_mydefault () {
- for v in wg_studio wg_ia wg_aa wg_ca wg_ib; do
- nmcli connection down "$v"
+down_not_master () {
+ git -C "$HOME/programs/config_local_arch" branch | awk '!/pp/{print ($1=="*")?$2:$1}' | while read -r v; do
+ nmcli connection down "wg_$v"
done
}
@@ -17,26 +17,26 @@ wg_aa_restore_default () {
esac
}
-# no toggle wg_mydefault, I want wg_mydefault to always on by default
-if ! [ "$1" ] || [ "$1" = mydefault ]; then
+# no toggle wg_master, I want wg_master to always on by default
+if ! [ "$1" ] || [ "$1" = master ]; then
wg_aa_restore_default
- down_not_mydefault
- nmcli connection up wg_mydefault
+ down_not_master
+ nmcli connection up wg_master
notify-send -u critical 'VPN disabled'
exit
fi
if nmcli -t --fields device,state device | grep -q "^wg_$1:connected$"; then
wg_aa_restore_default
- down_not_mydefault
- nmcli connection up wg_mydefault
+ down_not_master
+ nmcli connection up wg_master
notify-send -u critical "$1 VPN disabled"
else
if [ "$1" = aa ]; then
/usr/bin/alacritty -T aa --hold -e sh -c 'echo "Wait for aa sudo prompt and enter password, then manually close this window"; ssh -t aawg "sudo systemctl stop wg-quick@wg_ca && sudo systemctl start wg-quick@wg0"'
fi
- down_not_mydefault
- nmcli connection down wg_mydefault
+ down_not_master
+ nmcli connection down wg_master
nmcli connection up "wg_$1"
notify-send "$1 VPN enabled"
fi