From: Ian Kelling Date: Wed, 24 Apr 2024 19:34:28 +0000 (-0400) Subject: add new option X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=6d16d596ac0b53c22151c4a298e26735dd79e635;p=basic-https-conf add new option --- diff --git a/web-conf b/web-conf index 045a9b3..eb87f17 100755 --- a/web-conf +++ b/web-conf @@ -53,6 +53,9 @@ EXTRA_SETTINGS_FILE can be - for stdin which is root@$(hostname --fqdn) on this host. -f [ADDR:]PORT Enable proxy to [ADDR:]PORT. ADDR default is 127.0.0.1 -i Insecure, no ssl. +-l Allow failure of restarting apache/nginx. Useful for scripts where + we want to do the configuration, but don't mind if the web + server has some preexisting problem or other problem to fix later. -p PORT Main port to listen on, default 443. 80 implies -i. -r DIR DocumentRoot -s Allow symlinks from the doucment root @@ -71,8 +74,9 @@ ssl=true extra_settings= port=443 do_root_settings=true -temp=$(getopt -l help a:c:e:if:p:r:sth "$@") || usage 1 +temp=$(getopt -l help a:c:e:if:lp:r:sth "$@") || usage 1 vhostip='*' +allow_server_fail=false eval set -- "$temp" while true; do case $1 in @@ -84,6 +88,7 @@ while true; do -e) email="$2"; shift 2 ;; -f) proxy="$2"; shift 2 ;; -i) ssl=false; shift ;; + -l) allow_server_fail=true; shift ;; -p) port="$2"; shift 2 ;; -r) root="$2"; shift 2 ;; -t) do_root_settings=false; shift ;; @@ -350,7 +355,14 @@ EOF a2enmod -q ssl rewrite # rewrite needed for httpredir - service apache2 restart + + if $allow_server_fail; then + if ! service apache2 restart; then + echo "$0: warning: apache2 restart failed. ignoring due to -l flag" >&2 + fi + else + service apache2 restart + fi # I rarely look at how much traffic I get, so let's keep that info # around for longer than the default of 2 weeks. @@ -462,7 +474,13 @@ EOF EOF - service nginx restart + if $allow_server_fail; then + if ! service nginx restart; then + echo "$0: warning: nginx restart failed. ignoring due to -l flag" >&2 + fi + else + service nginx restart + fi fi ####### end if nginx