From d440addca3bbe612580e4365c0cded2bec52b94c Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Sat, 5 Jan 2019 02:11:49 -0700 Subject: [PATCH] added serverNames section --- .vscode/numbered-bookmarks.json | 4 +-- setup.sh | 44 ++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/.vscode/numbered-bookmarks.json b/.vscode/numbered-bookmarks.json index 839d03f..65c7b37 100644 --- a/.vscode/numbered-bookmarks.json +++ b/.vscode/numbered-bookmarks.json @@ -5,14 +5,14 @@ "bookmarks": [ -1, 17, - 36, + 38, -1, -1, -1, -1, -1, -1, - 420 + 110 ] } ] diff --git a/setup.sh b/setup.sh index b5b216d..f9d4966 100644 --- a/setup.sh +++ b/setup.sh @@ -27,11 +27,13 @@ unset CAChainPath unset DHPath # set variables -hostname=$(hostname) +serverNames_working=() +serverNames=() detectedIP=$(ip route get 1 | sed -n 's/^.*src \([0-9.]*\) .*$/\1/p') regexIP4="(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])" regexHostname="(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])" certbotFiles=(cert.pem chain.pem fullchain.pem privkey.pem) +hostname=$(hostname) configPath="./etc.${hostname}" # set tags to update @@ -76,6 +78,46 @@ while true; do done +### get server names for this installation +echo -e "\n${mag}NIGNX needs to know what hostnames it should answer. You can pick as many" +echo "hostnames as you like. Please ensure you provide fully-qualified domain" +echo "names unless you are providing special names such as 'localhost' and fully" +echo "understand what that means in this context." +echo -e "\nIf you're setting up this system with SSL, then make sure your hostnames" +echo "match what appears on your certificates!" +echo -e "\n${warn}You will be prompted to enter one hostname at a time." +echo "Provide a blank-entry (hit enter) when you're done." +echo -e "'X' will exit the script, as always${norm}\n" +while true; do + read -p "What hostnames should this server answer to? " inputServerName + case "${inputServerName}" in + '') + break + ;; + [Xx]*) + echo -e "\n${cyan}---exiting---\n${norm}" + exit 1 + ;; + *) + # check hostname for validity + if [[ ! "${inputServerName}" =~ ^${regexHostname}$ ]]; then + echo -e "\n${err}Invalid hostname${norm}" + else + serverNames_working+=("${inputServerName}") + fi + ;; + esac +done +# create new array with unqiue values only +declare -A uniqueSN +for name in "${serverNames_working[@]}"; do + uniqueSN["${name}"]="" +done +for sn in "${!uniqueSN[@]}"; do + serverNames+=("${sn}") +done + + ### SSL related options # using certbot? while true; do