Update VPN script
- rename openvpn-home.sh -> vpn-home.sh - enable OpenVPN and WireGuard - change logic
This commit is contained in:
@@ -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
45
bin/vpn-home.sh
Executable 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 "$@"
|
||||
Reference in New Issue
Block a user