subst for server_names.conf

This commit is contained in:
Asif Bacchus 2019-01-05 04:39:48 -07:00
parent d8a1e5b943
commit 5a428c027f
2 changed files with 15 additions and 4 deletions

View File

@ -12,7 +12,7 @@
-1, -1,
-1, -1,
-1, -1,
-1 524
] ]
} }
] ]

View File

@ -37,7 +37,9 @@ generateDH=0
hostname=$(hostname) hostname=$(hostname)
configPath="./etc.${hostname}" configPath="./etc.${hostname}"
# set tags to update # set tags and files to update
tag_servernames="<server name(s)>"
file_servernames="nginx/snippets/server_names.conf"
tag_sslcert="<path/to/your_ssl_certificate_fullchain>" tag_sslcert="<path/to/your_ssl_certificate_fullchain>"
tag_sslkey="<path/to/your_certificate_private_key.key>" tag_sslkey="<path/to/your_certificate_private_key.key>"
tag_dhparam="<path/to/your_dhparam.pem>" tag_dhparam="<path/to/your_dhparam.pem>"
@ -508,16 +510,25 @@ if [ "${usePHP}" -eq 1 ]; then
fi fi
: <<'COMMENTSECTION'
### Write configurations to template files ### Write configurations to template files
# let user know what's happening # let user know what's happening
echo -e "\n${mag}---------------------${norm}" echo -e "\n${mag}---------------------${norm}"
echo -e "${cyan}Updating template files now" echo -e "${cyan}Updating template files now"
# copy template files to working versions # copy template files to working versions
echo "copying files to dedicated directory for customization"
echo -e "${warn}${configPath}${norm}\n"
rm -rf "${configPath}" rm -rf "${configPath}"
cp -R ./etc "${configPath}" cp -R ./etc "${configPath}"
# process server names
echo -e "updating ${warn}${configPath}/${file_servernames}${norm}"
for name in "${serverNames[@]}"; do
sed -i "/${tag_servernames}/a \ \ ${name}" "${configPath}/${file_servernames}"
done
sed -i "/${tag_servernames}/d" "${configPath}/${file_servernames}"
# process SSL snippet # process SSL snippet
echo "updating SSL paths in snippet file" echo "updating SSL paths in snippet file"
sed -e "s%${tag_sslcert}%${CertPath}%" "${configPath}/nginx/snippets/ssl/ssl_certs.conf" sed -e "s%${tag_sslcert}%${CertPath}%" "${configPath}/nginx/snippets/ssl/ssl_certs.conf"
@ -528,7 +539,7 @@ echo "updating SSL configuration parameters file"
echo -e "s%${tag_dhparam}%${DHPath}%" "${configPath}/nginx/conf.d/mozModern_ssl.conf" 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" echo -e "s%${tag_cachain}%${CAChainPath}%" "${configPath}/nginx/conf.d/mozModern_ssl.conf"
COMMENTSECTION
# debug section # debug section
echo -e "\n${mag}---------------------${norm}" echo -e "\n${mag}---------------------${norm}"