From 1d7aac147eeace08fdc15f50b27026102286f215 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Fri, 4 Jan 2019 22:06:05 -0700 Subject: [PATCH] get local IP for substitution --- setup.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 34b439d..0cab614 100644 --- a/setup.sh +++ b/setup.sh @@ -30,6 +30,28 @@ echo "pressing ENTER (i.e. no answer)." echo -e "You may exit this script at any prompt by typing 'X'${norm}\n" - +### get local IP address +while true; do + read -p "What is this NGINX machine's primary local IP4 address? (${detectedIP}) " inputIP + case "${inputIP}" in + '') + IP4="${detectedIP}" + break + ;; + [Xx]*) + echo -e "\n${cyan}---exiting---\n${norm}" + exit 1 + ;; + *) + # check IP for validity + if [[ "${inputIP}" =~ ^${regexIP4}$ ]]; then + IP4="${inputIP}" + break + else + echo -e "\n${err}Invalid IP4 format (xxx.xxx.xxx.xxx)${norm}" + fi + ;; + esac +done exit 0