only validate and restart nginx if we're deployed. use REGEX when handling SSL and NON-SSL hosts

This commit is contained in:
Michael Hobbs
2015-04-24 11:31:27 -07:00
parent a18fa7afbe
commit 290745d324

View File

@@ -83,7 +83,7 @@ EOF
fi
SSL_VHOSTS=$(egrep "^${SSL_HOSTNAME_REGEX}$|^${SSL_HOSTNAME_ALT_REGEX}$" $VHOST_PATH || exit 0)
NONSSL_VHOSTS=$(egrep -v "^${SSL_HOSTNAME}$|^${SSL_HOSTNAME_ALT}$" $VHOST_PATH || exit 0)
NONSSL_VHOSTS=$(egrep -v "^${SSL_HOSTNAME_REGEX}$|^${SSL_HOSTNAME_ALT_REGEX}$" $VHOST_PATH || exit 0)
NGINX_TEMPLATE="$PLUGIN_PATH/nginx-vhosts/templates/nginx.ssl.conf.template"
while read line; do
@@ -118,12 +118,13 @@ EOF
dokku_log_info1 "Creating $SCHEME nginx.conf"
mv $NGINX_CONF "$DOKKU_ROOT/$APP/nginx.conf"
dokku_log_info1 "Running nginx-pre-reload"
pluginhook nginx-pre-reload $APP $DOKKU_APP_LISTEN_PORT $DOKKU_APP_LISTEN_IP
if is_deployed "$APP"; then
dokku_log_info1 "Running nginx-pre-reload"
pluginhook nginx-pre-reload $APP $DOKKU_APP_LISTEN_PORT $DOKKU_APP_LISTEN_IP
dokku_log_verbose "Reloading nginx"
validate_nginx
restart_nginx
dokku_log_verbose "Reloading nginx"
validate_nginx && restart_nginx
fi
echo "# THIS FILE IS GENERATED BY DOKKU - DO NOT EDIT, YOUR CHANGES WILL BE OVERWRITTEN" > $URLS_PATH
xargs -i echo "https://{}" <<< "${SSL_VHOSTS}" >> $URLS_PATH
@@ -137,8 +138,10 @@ EOF
dokku_log_info1 "VHOST support disabled, deleting nginx.conf"
rm "$DOKKU_ROOT/$APP/nginx.conf"
dokku_log_info1 "VHOST support disabled, reloading nginx after nginx.conf deletion"
restart_nginx
if is_deployed "$APP"; then
dokku_log_info1 "VHOST support disabled, reloading nginx after nginx.conf deletion"
validate_nginx && restart_nginx
fi
fi
fi
;;