add param for func vpn
This commit is contained in:
parent
5d141130a4
commit
d17026372b
@ -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"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user