From 9c7324565720f75349e38973f50bee38cc374087 Mon Sep 17 00:00:00 2001 From: Alessandro Partesotti Date: Mon, 24 Apr 2023 17:33:54 +0200 Subject: [PATCH 01/11] Update script to select custom lan network --- openvpn-install.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index c47e08f..deb7ed8 100755 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -310,6 +310,24 @@ function installQuestions() { PROTOCOL="tcp" ;; esac + until [[ $LAN_IP =~ "" ]]; do + + echo "Do wou want to specify a custom LAN network an subnet?" + echo " 1) NO (will use 10.8.0.0 and 255.255.255.0)" + echo " 2) YES" + until [[ $LAN_IP_CHOICE =~ ^[1-2]$ ]]; do + read -rp "Choice [1-2]: " -e -i 1 LAN_IP_CHOICE + done + case $LAN_IP_CHOICE in + 1) + $LAN_IP = "10.8.0.0" + $LAN_SUBNET_MASK = "255.255.255.0" + ;; + 2) + read -rp "IP NETWORK (e.g. 192.168.4.0): " -e -i 1 LAN_IP + read -rp "SUBNET (e.g. 255.255.255.0) : " -e -i 1 LAN_SUBNET_MASK + ;; + esac echo "" echo "What DNS resolvers do you want to use with the VPN?" echo " 1) Current system resolvers (from /etc/resolv.conf)" @@ -782,7 +800,7 @@ persist-key persist-tun keepalive 10 120 topology subnet -server 10.8.0.0 255.255.255.0 +server $LAN_IP $LAN_SUBNET_MASK ifconfig-pool-persist ipp.txt" >>/etc/openvpn/server.conf # DNS resolvers From e3d5b51517eafe48fca7847e99e6544630bcebf7 Mon Sep 17 00:00:00 2001 From: Alessandro Partesotti Date: Mon, 24 Apr 2023 17:33:54 +0200 Subject: [PATCH 02/11] Update script to select custom lan network --- openvpn-install.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index c47e08f..86262e0 100755 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -311,6 +311,24 @@ function installQuestions() { ;; esac echo "" + until [[ $LAN_IP =~ "" ]]; do + echo "Do wou want to specify a custom LAN network an subnet?" + echo " 1) NO (will use 10.8.0.0 and 255.255.255.0)" + echo " 2) YES" + until [[ $LAN_IP_CHOICE =~ ^[1-2]$ ]]; do + read -rp "Choice [1-2]: " -e -i 1 LAN_IP_CHOICE + done + case $LAN_IP_CHOICE in + 1) + $LAN_IP = "10.8.0.0" + $LAN_SUBNET_MASK = "255.255.255.0" + ;; + 2) + read -rp "IP NETWORK (e.g. 192.168.4.0): " -e -i 1 LAN_IP + read -rp "SUBNET (e.g. 255.255.255.0) : " -e -i 1 LAN_SUBNET_MASK + ;; + esac + echo "" echo "What DNS resolvers do you want to use with the VPN?" echo " 1) Current system resolvers (from /etc/resolv.conf)" echo " 2) Self-hosted DNS Resolver (Unbound)" @@ -782,7 +800,7 @@ persist-key persist-tun keepalive 10 120 topology subnet -server 10.8.0.0 255.255.255.0 +server $LAN_IP $LAN_SUBNET_MASK ifconfig-pool-persist ipp.txt" >>/etc/openvpn/server.conf # DNS resolvers From 563f0bcf7e93f597b0bb60dcdaf79b9cbad21737 Mon Sep 17 00:00:00 2001 From: Alessandro Partesotti Date: Mon, 24 Apr 2023 18:09:52 +0200 Subject: [PATCH 03/11] remove duplication --- openvpn-install.sh | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index bbbca37..deb7ed8 100755 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -312,24 +312,6 @@ function installQuestions() { esac until [[ $LAN_IP =~ "" ]]; do - echo "Do wou want to specify a custom LAN network an subnet?" - echo " 1) NO (will use 10.8.0.0 and 255.255.255.0)" - echo " 2) YES" - until [[ $LAN_IP_CHOICE =~ ^[1-2]$ ]]; do - read -rp "Choice [1-2]: " -e -i 1 LAN_IP_CHOICE - done - case $LAN_IP_CHOICE in - 1) - $LAN_IP = "10.8.0.0" - $LAN_SUBNET_MASK = "255.255.255.0" - ;; - 2) - read -rp "IP NETWORK (e.g. 192.168.4.0): " -e -i 1 LAN_IP - read -rp "SUBNET (e.g. 255.255.255.0) : " -e -i 1 LAN_SUBNET_MASK - ;; - esac - echo "" - until [[ $LAN_IP =~ "" ]]; do echo "Do wou want to specify a custom LAN network an subnet?" echo " 1) NO (will use 10.8.0.0 and 255.255.255.0)" echo " 2) YES" From 1f40d682cbc2b1b1dec3b836145a22897c0c9d0d Mon Sep 17 00:00:00 2001 From: Alessandro Partesotti Date: Mon, 24 Apr 2023 18:27:16 +0200 Subject: [PATCH 04/11] fix server address --- openvpn-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index deb7ed8..0f131d5 100755 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -800,7 +800,7 @@ persist-key persist-tun keepalive 10 120 topology subnet -server $LAN_IP $LAN_SUBNET_MASK +server $(LAN_IP) $(LAN_SUBNET_MASK) ifconfig-pool-persist ipp.txt" >>/etc/openvpn/server.conf # DNS resolvers From f0a23586d30b6c39769c103057aa0f9a9c538b46 Mon Sep 17 00:00:00 2001 From: Alessandro Partesotti Date: Mon, 24 Apr 2023 18:29:08 +0200 Subject: [PATCH 05/11] fix server address --- openvpn-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index 0f131d5..deb7ed8 100755 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -800,7 +800,7 @@ persist-key persist-tun keepalive 10 120 topology subnet -server $(LAN_IP) $(LAN_SUBNET_MASK) +server $LAN_IP $LAN_SUBNET_MASK ifconfig-pool-persist ipp.txt" >>/etc/openvpn/server.conf # DNS resolvers From 7405cc3d65bb1d3c4f104d1542e17e052f2b9b3e Mon Sep 17 00:00:00 2001 From: Alessandro Partesotti Date: Mon, 24 Apr 2023 18:32:35 +0200 Subject: [PATCH 06/11] fix choices --- openvpn-install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openvpn-install.sh b/openvpn-install.sh index deb7ed8..6704859 100755 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -325,9 +325,12 @@ function installQuestions() { ;; 2) read -rp "IP NETWORK (e.g. 192.168.4.0): " -e -i 1 LAN_IP + echo "NETWORK SET TO $LAN_IP" read -rp "SUBNET (e.g. 255.255.255.0) : " -e -i 1 LAN_SUBNET_MASK + echo "SUBNET SET TO $LAN_SUBNET_MASK" ;; esac + done echo "" echo "What DNS resolvers do you want to use with the VPN?" echo " 1) Current system resolvers (from /etc/resolv.conf)" From 6741de10180cdd57539247bfc741728c5893083f Mon Sep 17 00:00:00 2001 From: Alessandro Partesotti Date: Mon, 24 Apr 2023 18:41:56 +0200 Subject: [PATCH 07/11] autoinstall --- openvpn-install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/openvpn-install.sh b/openvpn-install.sh index 6704859..f67c61d 100755 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -639,6 +639,7 @@ function installOpenVPN() { IPV6_SUPPORT=${IPV6_SUPPORT:-n} PORT_CHOICE=${PORT_CHOICE:-1} PROTOCOL_CHOICE=${PROTOCOL_CHOICE:-1} + LAN_IP_CHOICE=${LAN_IP_CHOICE:-1} DNS=${DNS:-1} COMPRESSION_ENABLED=${COMPRESSION_ENABLED:-n} CUSTOMIZE_ENC=${CUSTOMIZE_ENC:-n} From 9deb44a2244e69bb58395325162849fe96d6aea6 Mon Sep 17 00:00:00 2001 From: Alessandro Partesotti Date: Mon, 24 Apr 2023 18:47:02 +0200 Subject: [PATCH 08/11] choice fix --- openvpn-install.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index f67c61d..42abdec 100755 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -310,7 +310,6 @@ function installQuestions() { PROTOCOL="tcp" ;; esac - until [[ $LAN_IP =~ "" ]]; do echo "Do wou want to specify a custom LAN network an subnet?" echo " 1) NO (will use 10.8.0.0 and 255.255.255.0)" @@ -330,7 +329,6 @@ function installQuestions() { echo "SUBNET SET TO $LAN_SUBNET_MASK" ;; esac - done echo "" echo "What DNS resolvers do you want to use with the VPN?" echo " 1) Current system resolvers (from /etc/resolv.conf)" From 798a0bb62ca398488bfd8c9b3143b104950776e4 Mon Sep 17 00:00:00 2001 From: Alessandro Partesotti Date: Mon, 24 Apr 2023 18:50:01 +0200 Subject: [PATCH 09/11] minor empty echo --- openvpn-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index 42abdec..1a88205 100755 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -310,7 +310,7 @@ function installQuestions() { PROTOCOL="tcp" ;; esac - + echo "" echo "Do wou want to specify a custom LAN network an subnet?" echo " 1) NO (will use 10.8.0.0 and 255.255.255.0)" echo " 2) YES" From 3af374f6f5344be1e6adb582f168c32d5c089d5c Mon Sep 17 00:00:00 2001 From: Alessandro Partesotti Date: Tue, 25 Apr 2023 21:36:51 +0200 Subject: [PATCH 10/11] fix --- openvpn-install.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index 1a88205..ff01413 100755 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -323,9 +323,13 @@ function installQuestions() { $LAN_SUBNET_MASK = "255.255.255.0" ;; 2) - read -rp "IP NETWORK (e.g. 192.168.4.0): " -e -i 1 LAN_IP + until [[ $LAN_IP =~ "" ]]; do + read -rp "IP NETWORK (e.g. 192.168.4.0): " -e -i 1 LAN_IP + done echo "NETWORK SET TO $LAN_IP" - read -rp "SUBNET (e.g. 255.255.255.0) : " -e -i 1 LAN_SUBNET_MASK + until [[ $LAN_SUBNET_MASK =~ "" ]]; do + read -rp "SUBNET (e.g. 255.255.255.0) : " -e -i 1 LAN_SUBNET_MASK + done echo "SUBNET SET TO $LAN_SUBNET_MASK" ;; esac From 2e05da8bf051848ae593f88bd8036cc33bf3831a Mon Sep 17 00:00:00 2001 From: Alessandro Partesotti Date: Tue, 25 Apr 2023 21:48:18 +0200 Subject: [PATCH 11/11] shellcheck issues --- openvpn-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index ff01413..0f37868 100755 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -319,8 +319,8 @@ function installQuestions() { done case $LAN_IP_CHOICE in 1) - $LAN_IP = "10.8.0.0" - $LAN_SUBNET_MASK = "255.255.255.0" + LAN_IP="10.8.0.0" + LAN_SUBNET_MASK="255.255.255.0" ;; 2) until [[ $LAN_IP =~ "" ]]; do