From 11b568aad56a75199da569797b165b0fd8e51e9b Mon Sep 17 00:00:00 2001 From: georglauterbach <44545919+georglauterbach@users.noreply.github.com> Date: Sun, 19 Jan 2025 11:37:09 +0100 Subject: [PATCH] chore: split `_setup_save_states` for restart purposes Signed-off-by: georglauterbach <44545919+georglauterbach@users.noreply.github.com> --- target/scripts/start-mailserver.sh | 7 ++++++- target/scripts/startup/setup.d/mail_state.sh | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/target/scripts/start-mailserver.sh b/target/scripts/start-mailserver.sh index 15e08aec..24a07562 100755 --- a/target/scripts/start-mailserver.sh +++ b/target/scripts/start-mailserver.sh @@ -122,7 +122,9 @@ function _register_functions() { _register_setup_function '_setup_logwatch' _register_setup_function '_setup_save_states' + # TODO _register_setup_function '_setup_apply_fixes_after_configuration' + _register_setup_function '_setup_adjust_state_permissions' if [[ ${ENABLE_MTA_STS} -eq 1 ]]; then _register_setup_function '_setup_mta_sts' @@ -186,7 +188,10 @@ _check # Ensure DMS only adjusts config files for a new container. # Container restarts should skip as they retain the modified config. if [[ -f /CONTAINER_START ]]; then - _log 'info' 'Container was restarted. Skipping setup routines.' + _log 'info' 'Container was restarted. Skipping most setup routines.' + # We cannot skip all setup routines because some need to run _after_ + # the initial setup (and hence, they cannot be moved to the check stack). + _setup_adjust_state_permissions else _setup fi diff --git a/target/scripts/startup/setup.d/mail_state.sh b/target/scripts/startup/setup.d/mail_state.sh index e819c138..d2fed814 100644 --- a/target/scripts/startup/setup.d/mail_state.sh +++ b/target/scripts/startup/setup.d/mail_state.sh @@ -83,7 +83,13 @@ function _setup_save_states() { # sourced from assocaiated path in /var/mail-state/ ($DEST): ln -s "${DEST}" "${SERVICEDIR}" done + else + _log 'debug' "'${STATEDIR}' is not present; Not consolidating state" + fi +} +function _setup_adjust_state_permissions() { + if [[ -d ${STATEDIR} ]]; then # This ensures the user and group of the files from the external mount have their # numeric ID values in sync. New releases where the installed packages order changes # can change the values in the Docker image, causing an ownership mismatch. @@ -119,7 +125,5 @@ function _setup_save_states() { # Ref: https://github.com/docker-mailserver/docker-mailserver/pull/3625 chmod 730 "${STATEDIR}/spool-postfix/maildrop" chmod 710 "${STATEDIR}/spool-postfix/public" - else - _log 'debug' "'${STATEDIR}' is not present; Not consolidating state" fi }