Refactor createVhosts.sh script
* Fixed line breaks * Remove duplicate block * Added error message to the cleanup process, conf dir is missing.
This commit is contained in:
parent
be51283e33
commit
178fa8e5dd
|
@ -126,6 +126,7 @@ _backend=""
|
|||
_listenip=""
|
||||
_debug=false
|
||||
_servicename=nginx
|
||||
_confpath=/etc/nginx
|
||||
while true; do
|
||||
case "$1" in
|
||||
--domain )
|
||||
|
@ -185,31 +186,20 @@ if test -n "$_root"; then
|
|||
_rootpath="root $_root;"
|
||||
fi
|
||||
|
||||
_check_host=success
|
||||
_check_host=failed
|
||||
_locationblock_http=""
|
||||
_locationblock_https=""
|
||||
if test -n "$_backend"; then
|
||||
echo "Verifying backend(s)..."
|
||||
if ! validate_host "$_backend"; then
|
||||
_check_host=failed
|
||||
fi
|
||||
|
||||
# Include backend for HTTP traffic if donotredirect is enabled
|
||||
#
|
||||
if [ "$_donotredirect" = "true" ]; then
|
||||
##Begin HEREDOC
|
||||
_locationblock_http=$(cat <<- EOF
|
||||
proxy_pass $_backend;
|
||||
include proxy_params;
|
||||
EOF
|
||||
)
|
||||
##End HEREDOC
|
||||
if validate_host "$_backend"; then
|
||||
_check_host=success
|
||||
fi
|
||||
|
||||
if [ "$_check_host" = "success" ]; then
|
||||
# Include backend for HTTP traffic if donotredirect is enabled
|
||||
#
|
||||
if [ "$_donotredirect" = "true" ]; then
|
||||
|
||||
##Begin HEREDOC
|
||||
_locationblock_http=$(cat <<- EOF
|
||||
proxy_pass $_backend;
|
||||
|
@ -217,6 +207,7 @@ _locationblock_http=$(cat <<- EOF
|
|||
EOF
|
||||
)
|
||||
##End HEREDOC
|
||||
|
||||
fi
|
||||
|
||||
##Begin HEREDOC
|
||||
|
@ -225,7 +216,8 @@ _locationblock_https=$(cat <<- EOF
|
|||
include proxy_params;
|
||||
EOF
|
||||
)
|
||||
##End HEREDOC
|
||||
##End HEREDOC
|
||||
|
||||
else
|
||||
err "Invalid hostname: $_backend. Not resolvable!"
|
||||
fi
|
||||
|
@ -257,7 +249,7 @@ if test -d "$_confpath"; then
|
|||
echo "Yes!"
|
||||
else
|
||||
echo "No!"
|
||||
clean_up
|
||||
clean_up "Conf path doesn't exists!"
|
||||
fi
|
||||
|
||||
##
|
||||
|
|
Loading…
Reference in New Issue