diff --git a/.vscode/numbered-bookmarks.json b/.vscode/numbered-bookmarks.json index 9aa6c22..839d03f 100644 --- a/.vscode/numbered-bookmarks.json +++ b/.vscode/numbered-bookmarks.json @@ -5,14 +5,14 @@ "bookmarks": [ -1, 17, + 36, -1, -1, -1, -1, -1, -1, - -1, - -1 + 420 ] } ] diff --git a/setup.sh b/setup.sh index 7ac0da8..ed5a6f5 100644 --- a/setup.sh +++ b/setup.sh @@ -17,6 +17,7 @@ norm="\e[0m" ### set variables +# clear variables unset IP4 unset useCertbot unset CertbotDomain @@ -25,10 +26,19 @@ unset KeyPath unset CAChainPath unset DHPath -certbotFiles=(cert.pem chain.pem fullchain.pem privkey.pem) +# set variables +hostname=$(hostname) 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) +configPath="./etc.${hostname}" + +# set tags to update +tag_sslcert="" +tag_sslkey="" +tag_dhparam="" +tag_cachain="" ### quick intro for the user @@ -394,6 +404,27 @@ if [ "${usePHP}" -eq 1 ]; then fi +### Write configurations to template files +# let user know what's happening +echo -e "\n${mag}---------------------${norm}" +echo -e "${cyan}Updating template files now" + +# copy template files to working versions +rm -rf "${configPath}" +cp -R ./etc "${configPath}" + +# process SSL snippet +echo "updating SSL paths in snippet file" +sed -e "s%${tag_sslcert}%${CertPath}%" "${configPath}/nginx/snippets/ssl/ssl_certs.conf" +sed -e "s%${tag_sslkey}%${KeyPath}%" "${configPath}/nginx/snippets/ssl/ssl_certs.conf" + +# process mozModern SSL configuration +echo "updating SSL configuration parameters file" +echo -e "s%${tag_dhparam}%${DHPath}%" "${configPath}/nginx/conf.d/mozModern_ssl.conf" +echo -e "s%${tag_cachain}%${CAChainPath}%" "${configPath}/nginx/conf.d/mozModern_ssl.conf" + + + # debug section echo -e "\n${mag}---------------------${norm}" echo "Local IP4: $IP4"