From ba2527d67b010dd8d647bc2287d0eec05d74e12b Mon Sep 17 00:00:00 2001 From: Orazio <22700499+orazioedoardo@users.noreply.github.com> Date: Sat, 25 Dec 2021 14:51:56 +0100 Subject: [PATCH] Fix vpnGW variable creation when pivpnNET was 10.X.0.0 or 10.0.0.0 Bash built-in substitution doesn't work in those cases, example: $ pivpnNET=10.34.0.0 $ vpnGw="${pivpnNET/.0/.1}" $ echo $vpnGw 10.34.1.0 --- auto_install/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auto_install/install.sh b/auto_install/install.sh index 32a8419..177deb8 100755 --- a/auto_install/install.sh +++ b/auto_install/install.sh @@ -1122,7 +1122,7 @@ setOpenVPNDefaultVars(){ if [ -z "$pivpnNET" ]; then pivpnNET="$(generateRandomSubnet)" fi - vpnGw="${pivpnNET/.0/.1}" + vpnGw="$(cut -d '.' -f 1-3 <<< "${pivpnNET}").1" } setWireguardDefaultVars(){ @@ -1134,7 +1134,7 @@ setWireguardDefaultVars(){ if [ -z "$pivpnNET" ]; then pivpnNET="$(generateRandomSubnet)" fi - vpnGw="${pivpnNET/.0/.1}" + vpnGw="$(cut -d '.' -f 1-3 <<< "${pivpnNET}").1" # Allow custom allowed IPs via unattend setupVARs file. Use default if not provided. if [ -z "$ALLOWED_IPS" ]; then # Forward all traffic through PiVPN (i.e. full-tunnel), may be modified by