From 6c575adae24d57d037501a974f187992ec47c509 Mon Sep 17 00:00:00 2001 From: Georg Lauterbach <44545919+aendeavor@users.noreply.github.com> Date: Mon, 1 Feb 2021 18:39:05 +0100 Subject: [PATCH] correct application of the new SUPERVISOR_LOGLEVEL variable (#1787) * correct application of the new SUPERVISOR_LOGLEVEL variable * correcting default log level adjustment * replacing grep &>/dev/null with grep -q --- README.md | 14 ++++++------ target/scripts/start-mailserver.sh | 35 +++++++++++++++++------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index a22ceff6..2a17e76a 100644 --- a/README.md +++ b/README.md @@ -156,17 +156,17 @@ If you'd like to change, patch or alter files or behavior of `docker-mailserver` # ! THIS IS AN EXAMPLE ! # If you modify any supervisord configuration, make sure -# to run "supervisorctl update" afterwards. +# to run `supervisorctl update` and/or `supervisorctl reload` afterwards. -set -euo pipefail -echo 'user-patches.sh started' +# shellcheck source=/dev/null +. /usr/local/bin/helper-functions.sh + +_notify 'Applying user-patches' if ! grep '192.168.0.1' /etc/hosts then echo -e '192.168.0.1 some.domain.com' >> /etc/hosts fi - -echo 'user-patches.sh finished successfully' ``` And you're done. The user patches script runs right before starting daemons. That means, all the other configuration is in place, so the script can make final adjustments. @@ -224,7 +224,7 @@ This example provides you only with a basic example of what a minimal setup coul version: '3.8' services: - mail: + mailserver: image: docker.io/mailserver/docker-mailserver:latest hostname: mail # ${HOSTNAME} domainname: domain.com # ${DOMAINNAME} @@ -265,7 +265,7 @@ volumes: version: '3.8' services: - mail: + mailserver: image: docker.io/mailserver/docker-mailserver:latest hostname: mail # ${HOSTNAME} domainname: domain.com # ${DOMAINNAME} diff --git a/target/scripts/start-mailserver.sh b/target/scripts/start-mailserver.sh index ac4c7da4..b84c4a55 100755 --- a/target/scripts/start-mailserver.sh +++ b/target/scripts/start-mailserver.sh @@ -356,22 +356,27 @@ function setup function _setup_supervisor { - case ${SUPERVISOR_LOGLEVEL} in - critical | error | warn | info | debug ) - sed -i -E \ - "s+loglevel.*+loglevel = ${SUPERVISOR_LOGLEVEL}+g" \ - /etc/supervisor/supervisord.conf - ;; - * ) - _notify 'warn' \ - "SUPERVISOR_LOGLEVEL value '${SUPERVISOR_LOGLEVEL}' unknown. Defaulting to 'warn'" - sed -i -E \ - "s+loglevel.*+loglevel = warn+g" \ - /etc/supervisor/supervisord.conf - ;; - esac + if ! grep -q "loglevel = ${SUPERVISOR_LOGLEVEL}" /etc/supervisor/supervisord.conf + then + case ${SUPERVISOR_LOGLEVEL} in + critical | error | warn | info | debug ) + sed -i -E \ + "s+loglevel.*+loglevel = ${SUPERVISOR_LOGLEVEL}+g" \ + /etc/supervisor/supervisord.conf - supervisorctl update + ;; + * ) + _notify 'error' \ + "SUPERVISOR_LOGLEVEL value '${SUPERVISOR_LOGLEVEL}' unknown. Defaulting to 'warn'" + + sed -i -E \ + "s+loglevel.*+loglevel = warn+g" \ + /etc/supervisor/supervisord.conf + ;; + esac + + supervisorctl reload + fi } function _setup_default_vars