petits-scripts-persos/switch-vpn
2022-07-04 16:31:39 +02:00

28 lines
726 B
Bash
Executable File

#!/bin/sh
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
nmcli connection down rezine_vpn37_udp
sleep 1
nmcli connection show rezine_vpn37_udp | grep 'VPN connected' &>/dev/null
[ "$?" -eq 0 ] && say 'Toujours connecté :(' || say 'stoppé :)'
else
say 'Bad script usage. Action not known'
fi