From cbcc3823d37031587acde5386e335826b2effa96 Mon Sep 17 00:00:00 2001 From: Casper Date: Tue, 19 Apr 2022 21:09:25 +0200 Subject: [PATCH] Fix changedetector restart loop (#2548) * only restart changedetector, if exit is unexpected. * prevent supervisord from restarting changedetector on error --> endless loop * add quotes --- target/scripts/check-for-changes.sh | 6 +++--- target/scripts/helpers/error.sh | 2 +- target/supervisor/conf.d/supervisor-app.conf | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/target/scripts/check-for-changes.sh b/target/scripts/check-for-changes.sh index 4516529d..daeaf590 100755 --- a/target/scripts/check-for-changes.sh +++ b/target/scripts/check-for-changes.sh @@ -24,19 +24,19 @@ _obtain_hostname_and_domainname if ! cd /tmp/docker-mailserver &>/dev/null then - _exit_with_error "Could not change into '/tmp/docker-mailserver/' directory" + _exit_with_error "Could not change into '/tmp/docker-mailserver/' directory" 0 fi # check postfix-accounts.cf exist else break if [[ ! -f postfix-accounts.cf ]] then - _exit_with_error "'/tmp/docker-mailserver/postfix-accounts.cf' is missing" + _exit_with_error "'/tmp/docker-mailserver/postfix-accounts.cf' is missing" 0 fi # verify checksum file exists; must be prepared by start-mailserver.sh if [[ ! -f ${CHKSUM_FILE} ]] then - _exit_with_error "'/tmp/docker-mailserver/${CHKSUM_FILE}' is missing" + _exit_with_error "'/tmp/docker-mailserver/${CHKSUM_FILE}' is missing" 0 fi REGEX_NEVER_MATCH="(?\!)" diff --git a/target/scripts/helpers/error.sh b/target/scripts/helpers/error.sh index cafbe2bf..1a7b95e0 100644 --- a/target/scripts/helpers/error.sh +++ b/target/scripts/helpers/error.sh @@ -10,7 +10,7 @@ function _exit_with_error fi _log 'error' 'Aborting' - exit 1 + exit "${2:-1}" } # `dms_panic` methods are appropriate when the type of error is a not recoverable, diff --git a/target/supervisor/conf.d/supervisor-app.conf b/target/supervisor/conf.d/supervisor-app.conf index 23ef7204..dde4f0eb 100644 --- a/target/supervisor/conf.d/supervisor-app.conf +++ b/target/supervisor/conf.d/supervisor-app.conf @@ -119,7 +119,6 @@ command=/usr/local/bin/postfix-wrapper.sh startsecs=0 stopwaitsecs=55 autostart=false -autorestart=true stdout_logfile=/var/log/supervisor/%(program_name)s.log stderr_logfile=/var/log/supervisor/%(program_name)s.log command=/usr/local/bin/check-for-changes.sh