Add subnet check

- Add a check for custom VPN subnets. Those can only be specified
  during initial VPN install.
  Ref: 1834b79
This commit is contained in:
hwdsl2 2022-05-10 08:47:59 -05:00
parent 1834b792eb
commit 95d9fc4e03
4 changed files with 48 additions and 0 deletions

View File

@ -146,6 +146,17 @@ check_client_name() {
fi
}
check_subnets() {
if [ -n "$VPN_L2TP_NET" ] || [ -n "$VPN_L2TP_LOCAL" ] || [ -n "$VPN_L2TP_POOL" ] \
|| [ -n "$VPN_XAUTH_NET" ] || [ -n "$VPN_XAUTH_POOL" ]; then
if grep -qs "hwdsl2 VPN script" /etc/sysctl.conf; then
echo "Error: You may only specify custom subnets during initial VPN install." >&2
echo " See Advanced usage -> Customize VPN subnets for more information." >&2
exit 1
fi
fi
}
start_setup() {
bigecho "VPN setup in progress... Please be patient."
mkdir -p /opt/src
@ -557,6 +568,7 @@ vpnsetup() {
check_dns
check_server_dns
check_client_name
check_subnets
check_libreswan
start_setup
install_setup_pkgs

View File

@ -128,6 +128,17 @@ check_client_name() {
fi
}
check_subnets() {
if [ -n "$VPN_L2TP_NET" ] || [ -n "$VPN_L2TP_LOCAL" ] || [ -n "$VPN_L2TP_POOL" ] \
|| [ -n "$VPN_XAUTH_NET" ] || [ -n "$VPN_XAUTH_POOL" ]; then
if grep -qs "hwdsl2 VPN script" /etc/sysctl.conf; then
echo "Error: You may only specify custom subnets during initial VPN install." >&2
echo " See Advanced usage -> Customize VPN subnets for more information." >&2
exit 1
fi
fi
}
start_setup() {
bigecho "VPN setup in progress... Please be patient."
mkdir -p /opt/src
@ -572,6 +583,7 @@ vpnsetup() {
check_dns
check_server_dns
check_client_name
check_subnets
check_libreswan
start_setup
install_setup_pkgs

View File

@ -156,6 +156,17 @@ check_client_name() {
fi
}
check_subnets() {
if [ -n "$VPN_L2TP_NET" ] || [ -n "$VPN_L2TP_LOCAL" ] || [ -n "$VPN_L2TP_POOL" ] \
|| [ -n "$VPN_XAUTH_NET" ] || [ -n "$VPN_XAUTH_POOL" ]; then
if grep -qs "hwdsl2 VPN script" /etc/sysctl.conf; then
echo "Error: You may only specify custom subnets during initial VPN install." >&2
echo " See Advanced usage -> Customize VPN subnets for more information." >&2
exit 1
fi
fi
}
start_setup() {
bigecho "VPN setup in progress... Please be patient."
mkdir -p /opt/src
@ -700,6 +711,7 @@ vpnsetup() {
check_dns
check_server_dns
check_client_name
check_subnets
check_libreswan
start_setup
install_setup_pkgs

View File

@ -154,6 +154,17 @@ check_client_name() {
fi
}
check_subnets() {
if [ -n "$VPN_L2TP_NET" ] || [ -n "$VPN_L2TP_LOCAL" ] || [ -n "$VPN_L2TP_POOL" ] \
|| [ -n "$VPN_XAUTH_NET" ] || [ -n "$VPN_XAUTH_POOL" ]; then
if grep -qs "hwdsl2 VPN script" /etc/sysctl.conf; then
echo "Error: You may only specify custom subnets during initial VPN install." >&2
echo " See Advanced usage -> Customize VPN subnets for more information." >&2
exit 1
fi
fi
}
check_iptables() {
if [ -x /sbin/iptables ] && ! iptables -nL INPUT >/dev/null 2>&1; then
exiterr "IPTables check failed. Reboot and re-run this script."
@ -672,6 +683,7 @@ vpnsetup() {
check_dns
check_server_dns
check_client_name
check_subnets
check_iptables
check_libreswan
start_setup