From d17026372b04dfdee5226448e6be77e6a02ab0e6 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Tue, 24 May 2022 12:12:50 +0300 Subject: [PATCH] add param for func vpn --- sub/bash/functions | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sub/bash/functions b/sub/bash/functions index 0efade7..9428d51 100644 --- a/sub/bash/functions +++ b/sub/bash/functions @@ -154,13 +154,17 @@ py() { # toggle wireguard vpn with interface /etc/wireguard/wg0.conf vpn() { local STATUS SERVICE CONFIG CONFIGFILE - CONFIG="wg0" + CONFIG="$1" + + test -z "$CONFIG" && CONFIG="wg0" + CONFIGFILE="/etc/wireguard/$CONFIG.conf" - test -e "$CONFIGFILE" || (echo "Config '$CONFIGFILE' not exists" >&2; return 1) + test -e "$CONFIGFILE" || (echo "Config '$CONFIGFILE' not exists" >&2; return 1) && ( SERVICE="wg-quick@$CONFIG.service" systemctl --quiet is-active "$SERVICE" && sudo systemctl stop "$SERVICE" || sudo systemctl start "$SERVICE" + ) }