add func vpn to toggle wireguard vpn

This commit is contained in:
TheK4n 2022-05-23 21:56:31 +03:00
parent 574d8827c3
commit 2f49aa7b3b

View File

@ -151,3 +151,10 @@ py() {
test -z "$@" && ipython -i -c "q = exit" || python3 $@ test -z "$@" && ipython -i -c "q = exit" || python3 $@
} }
vpn() {
local STATUS SERVICE
SERVICE="wg-quick@wg0.service"
STATUS=$(systemctl status $SERVICE | grep Active | awk -F ": " '{printf $2}' | awk -F " " '{printf $1}')
test $STATUS = "inactive" && sudo systemctl start $SERVICE || sudo systemctl stop $SERVICE
}