blob: b0f26a8b91104577dd63c3cb0e3b4bb0f597fcab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#!/bin/sh
# toggle VPN
down_not_mydefault () {
for v in wg_studio wg_ia; 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
|