get local IP for substitution

This commit is contained in:
Asif Bacchus 2019-01-04 22:06:05 -07:00
parent bf28658a43
commit 1d7aac147e

View File

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