diff options
author | sinanmohd <sinan@sinanmohd.com> | 2024-07-04 22:05:12 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2024-07-04 22:05:18 +0530 |
commit | 67812a9ae3136aaf76b1d83d561c5bc010951afe (patch) | |
tree | 9c41ca3bcfbdfd87a16326acabd4d8b6baaf9b66 /vpn | |
parent | f814f92a20edc3e19b8cac0d1380f89690a68732 (diff) |
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 |