From 22ad66e37250e75a0f2f0be7fc0687c7953b72b6 Mon Sep 17 00:00:00 2001 From: noogen Date: Wed, 28 Sep 2022 10:03:59 -0500 Subject: [PATCH] update startup --- .../include/letsencrypt-acme-challenge.conf | 2 +- .../{server.conf => server-conf.example} | 0 files/root/bin/my-startup.sh | 18 +++++++++++------- files/sbin/my_init | 3 ++- 4 files changed, 14 insertions(+), 9 deletions(-) rename files/etc/nginx/sites-enabled/{server.conf => server-conf.example} (100%) diff --git a/files/etc/nginx/include/letsencrypt-acme-challenge.conf b/files/etc/nginx/include/letsencrypt-acme-challenge.conf index 4a60e85..8efcc28 100644 --- a/files/etc/nginx/include/letsencrypt-acme-challenge.conf +++ b/files/etc/nginx/include/letsencrypt-acme-challenge.conf @@ -19,7 +19,7 @@ location ^~ /.well-known/acme-challenge/ { # there to "webroot". # Do NOT use alias, use root! Target directory is located here: # /var/www/common/letsencrypt/.well-known/acme-challenge/ - root /data/letsencrypt-acme-challenge; + root /app/letsencrypt-acme-challenge; } # Hide /acme-challenge subdirectory and return 404 on all requests. diff --git a/files/etc/nginx/sites-enabled/server.conf b/files/etc/nginx/sites-enabled/server-conf.example similarity index 100% rename from files/etc/nginx/sites-enabled/server.conf rename to files/etc/nginx/sites-enabled/server-conf.example diff --git a/files/root/bin/my-startup.sh b/files/root/bin/my-startup.sh index 8010603..216fa8f 100755 --- a/files/root/bin/my-startup.sh +++ b/files/root/bin/my-startup.sh @@ -2,8 +2,8 @@ set -e function die { - echo >&2 "$@" - exit 1 + echo >&2 "$@" + exit 1 } ####################################### @@ -12,15 +12,19 @@ function die { # String: value to log ####################################### function log { - if [[ "$@" ]]; then echo "[`date +'%Y-%m-%d %T'`] $@"; - else echo; fi + if [[ "$@" ]]; then echo "[`date +'%Y-%m-%d %T'`] $@"; + else echo; fi } if [ -n "$SERVER_CONF" ] ; then - log "Getting new server.conf" - mv /app/etc/nginx/sites-enabled/server.conf /app/etc/nginx/sites-enabled/server.bak - curl -SL $SERVER_CONF --output /app/etc/nginx/sites-enabled/server.conf + # backup old config if exists + if [ -f /app/etc/nginx/sites-enabled/server.conf ]; then + mv /app/etc/nginx/sites-enabled/server.conf /app/etc/nginx/sites-enabled/server.bak + fi + + log "Getting new server.conf" + curl -SL $SERVER_CONF --output /app/etc/nginx/sites-enabled/server.conf fi echo "*** Running cron" diff --git a/files/sbin/my_init b/files/sbin/my_init index ea7bd5a..f213faf 100755 --- a/files/sbin/my_init +++ b/files/sbin/my_init @@ -12,7 +12,8 @@ if [ ! -f /etc/nginx/nginx.conf ]; then fi mkdir -p /tmp/nginx/cache \ - /tmp/nginx/body + /tmp/nginx/body \ + /app/letsencrypt-acme-challenge chown -R www-data:nginx /tmp/nginx # if there is nginx.new, then make it current and backup existing