aboutsummaryrefslogtreecommitdiff
path: root/vpn
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2024-07-04 22:05:12 +0530
committersinanmohd <sinan@sinanmohd.com>2024-07-04 22:05:18 +0530
commit67812a9ae3136aaf76b1d83d561c5bc010951afe (patch)
tree9c41ca3bcfbdfd87a16326acabd4d8b6baaf9b66 /vpn
parentf814f92a20edc3e19b8cac0d1380f89690a68732 (diff)
vpn: refactorHEADmaster
Diffstat (limited to 'vpn')
-rwxr-xr-xvpn26
1 files changed, 10 insertions, 16 deletions
diff --git a/vpn b/vpn
index 0eef247..e1eb205 100755
--- a/vpn
+++ b/vpn
@@ -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