petits-scripts-persos/switch-vpn

28 lines
726 B
Plaintext
Raw Normal View History

2022-02-10 08:05:07 +00:00
#!/bin/sh
2022-07-04 14:31:39 +00:00
function say () {
notify-send 'VPN UDP' "$1"
}
action="$1"
if [ -z "$1" ] ; then
if [ -n "$(nmcli connection show rezine_vpn37_udp | grep activated)" ] ; then
action=start
else
action=stop
fi
fi
if [ "$action" = "start" ] ; then
nmcli connection up rezine_vpn37_udp
sleep 1
nmcli connection show rezine_vpn37_udp | grep 'VPN connected' &>/dev/null
[ "$?" -eq 0 ] && say 'Connecté :)' || say 'Non connecté :('
elif [ "$action" = "stop" ] ; then
2022-02-10 08:05:07 +00:00
nmcli connection down rezine_vpn37_udp
2022-07-04 14:31:39 +00:00
sleep 1
nmcli connection show rezine_vpn37_udp | grep 'VPN connected' &>/dev/null
[ "$?" -eq 0 ] && say 'Toujours connecté :(' || say 'stoppé :)'
2022-02-10 08:05:07 +00:00
else
2022-07-04 14:31:39 +00:00
say 'Bad script usage. Action not known'
2022-02-10 08:05:07 +00:00
fi