Update VPN script

- rename openvpn-home.sh -> vpn-home.sh
- enable OpenVPN and WireGuard
- change logic
This commit is contained in:
Martin Blazik
2022-07-17 08:29:26 +02:00
parent 7f6de7539e
commit 57f90d4a44
2 changed files with 45 additions and 9 deletions

View File

@@ -1,9 +0,0 @@
#!/bin/bash
SERVICE_NAME="openvpn@home.service"
if (( $# < 1 )); then
sudo systemctl status $SERVICE_NAME
else
sudo systemctl $1 $SERVICE_NAME
fi

45
bin/vpn-home.sh Executable file
View File

@@ -0,0 +1,45 @@
#!/bin/bash
OVPN_SERVICE="openvpn@home.service"
OVPN_CONF="/etc/openvpn/home.conf"
WG_NAME="wg-home"
WG_SERVICE="wg-quick@wg-home"
WG_CONF="/etc/wireguard/wg-home.conf"
function run() {
echo "# $*"
eval sudo "$@"
}
function ovpn_ctl() {
if (( $# < 1 )); then
run systemctl status $OVPN_SERVICE
else
run systemctl $1 $OVPN_SERVICE
fi
}
function wg_ctl() {
local op=${1:-status}
case "$op" in
show)
run wg show all
;;
up)
run wg-quick up $WG_NAME
;;
down)
run wg-quick down $WG_NAME
;;
down-up)
run wg-quick down $WG_NAME
run wg-quick up $WG_NAME
;;
*)
run systemctl $op $WG_SERVICE
;;
esac
}
wg_ctl "$@"