diff options
Diffstat (limited to 'vpn')
-rwxr-xr-x | vpn | 26 |
1 files changed, 10 insertions, 16 deletions
@@ -3,24 +3,18 @@ note() { command -v notify-send > /dev/null && - notify-send " vpn" "$1" + notify-send " vpn" "$1" printf "\n%s\n" "$1" } -main() -{ - wg_conf="${1:-wg0}" - - if ip -details link show "$wg_conf" 2> /dev/null | grep --quiet "wireguard" - then - sudo -A -p " halt, authentication required: " wg-quick down "$wg_conf" && - note "connection was dropped" - else - sudo -A -p " init, authentication required: " wg-quick up "$wg_conf" && - note "traffic routed through $wg_conf" - fi && command -v wip > /dev/null && - wip -} +wg_conf="${1:-kay}" -main "$@" +if systemctl status "wg-quick-${wg_conf}.service" > /dev/null 2>&1; then + sudo -A systemctl stop "wg-quick-${wg_conf}.service" && + note "connection was dropped" +else + sudo -A systemctl start "wg-quick-${wg_conf}.service" && + note "traffic routed through $wg_conf" +fi && + command -v wip > /dev/null && wip |