chore: split `_setup_save_states` for restart purposes

Signed-off-by: georglauterbach <44545919+georglauterbach@users.noreply.github.com>
This commit is contained in:
georglauterbach 2025-01-19 11:37:09 +01:00
parent ae5e2c5a99
commit 11b568aad5
No known key found for this signature in database
GPG Key ID: F367F7C43C118578
2 changed files with 12 additions and 3 deletions

View File

@ -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

View File

@ -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
}