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
This commit is contained in:
Orazio 2021-12-25 14:51:56 +01:00
parent 85b3e82274
commit ba2527d67b

View file

@ -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