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 committed 2015-04-24 11:31:27 -07:00
1 parent a18fa7afbe
commit 290745d324
1 file changed
+11 -8
+11 -8
View File
@@ -83,7 +83,7 @@ EOF
fi fi
SSL_VHOSTS=$(egrep "^${SSL_HOSTNAME_REGEX}$|^${SSL_HOSTNAME_ALT_REGEX}$" $VHOST_PATH || exit 0) 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" NGINX_TEMPLATE="$PLUGIN_PATH/nginx-vhosts/templates/nginx.ssl.conf.template"
while read line; do while read line; do
@@ -118,12 +118,13 @@ EOF
dokku_log_info1 "Creating $SCHEME nginx.conf" dokku_log_info1 "Creating $SCHEME nginx.conf"
mv $NGINX_CONF "$DOKKU_ROOT/$APP/nginx.conf" mv $NGINX_CONF "$DOKKU_ROOT/$APP/nginx.conf"
dokku_log_info1 "Running nginx-pre-reload" if is_deployed "$APP"; then
pluginhook nginx-pre-reload $APP $DOKKU_APP_LISTEN_PORT $DOKKU_APP_LISTEN_IP 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" dokku_log_verbose "Reloading nginx"
validate_nginx validate_nginx && restart_nginx
restart_nginx fi
echo "# THIS FILE IS GENERATED BY DOKKU - DO NOT EDIT, YOUR CHANGES WILL BE OVERWRITTEN" > $URLS_PATH 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 xargs -i echo "https://{}" <<< "${SSL_VHOSTS}" >> $URLS_PATH
@@ -137,8 +138,10 @@ EOF
dokku_log_info1 "VHOST support disabled, deleting nginx.conf" dokku_log_info1 "VHOST support disabled, deleting nginx.conf"
rm "$DOKKU_ROOT/$APP/nginx.conf" rm "$DOKKU_ROOT/$APP/nginx.conf"
dokku_log_info1 "VHOST support disabled, reloading nginx after nginx.conf deletion" if is_deployed "$APP"; then
restart_nginx dokku_log_info1 "VHOST support disabled, reloading nginx after nginx.conf deletion"
validate_nginx && restart_nginx
fi
fi fi
fi fi
;; ;;