From 5fd223790d43b52c3b68e11046c6b5d286ddc3b0 Mon Sep 17 00:00:00 2001 From: ralphg6 Date: Sun, 11 Aug 2024 05:21:17 -0300 Subject: [PATCH] Fix IP Detection conditions --- openvpn-install.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index 083ea7a..a18e915 100755 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -283,9 +283,12 @@ function installQuestions() { echo "It seems this server is behind NAT. What is its public IPv4 address or hostname?" echo "We need it for the clients to connect to the server." + if [[ -z $ENDPOINT ]]; then + DEFAULT_ENDPOINT=$(resolvePublicIP) + fi + until [[ $ENDPOINT != "" ]]; do - PUBLIC_IP=$(resolvePublicIP) - read -rp "Public IPv4 address or hostname: " -e -i "$PUBLIC_IP" ENDPOINT + read -rp "Public IPv4 address or hostname: " -e -i "$DEFAULT_ENDPOINT" ENDPOINT done fi @@ -664,9 +667,9 @@ function installOpenVPN() { PASS=${PASS:-1} CONTINUE=${CONTINUE:-y} - until [[ $ENDPOINT != "" ]]; do + if [[ -z $ENDPOINT ]]; then ENDPOINT=$(resolvePublicIP) - done + fi fi # Run setup questions first, and set other variables if auto-install