chore: reduce nesting and improve readability in `mail_state.sh`
Signed-off-by: georglauterbach <44545919+georglauterbach@users.noreply.github.com>
This commit is contained in:
parent
a6fe9f5bcc
commit
65f419d741
|
@ -3,17 +3,17 @@
|
||||||
# Consolidate all states into a single directory
|
# Consolidate all states into a single directory
|
||||||
# (/var/mail-state) to allow persistence using docker volumes
|
# (/var/mail-state) to allow persistence using docker volumes
|
||||||
function _setup_save_states() {
|
function _setup_save_states() {
|
||||||
local DEST DESTDIR SERVICEDIR SERVICEDIRS SERVICEFILE SERVICEFILES
|
if [[ ! -d ${DMS_STATE_DIR:?DMS_STATE_DIR is not set} ]]; then
|
||||||
|
_log 'debug' "'${DMS_STATE_DIR}' is not present - not consolidating state"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -d ${DMS_STATE_DIR} ]]; then
|
|
||||||
_log 'debug' "Consolidating all state onto ${DMS_STATE_DIR}"
|
_log 'debug' "Consolidating all state onto ${DMS_STATE_DIR}"
|
||||||
|
|
||||||
|
local DEST DESTDIR SERVICEDIR SERVICEDIRS SERVICEFILE SERVICEFILES
|
||||||
|
|
||||||
# Always enabled features:
|
# Always enabled features:
|
||||||
SERVICEDIRS=(
|
SERVICEDIRS=( 'lib/logrotate' 'lib/postfix' 'spool/postfix' )
|
||||||
lib/logrotate
|
|
||||||
lib/postfix
|
|
||||||
spool/postfix
|
|
||||||
)
|
|
||||||
|
|
||||||
# Only consolidate state for services that are enabled
|
# Only consolidate state for services that are enabled
|
||||||
# Notably avoids copying over 200MB for the ClamAV database
|
# Notably avoids copying over 200MB for the ClamAV database
|
||||||
|
@ -81,13 +81,14 @@ function _setup_save_states() {
|
||||||
# sourced from assocaiated path in /var/mail-state/ ($DEST):
|
# sourced from assocaiated path in /var/mail-state/ ($DEST):
|
||||||
ln -s "${DEST}" "${SERVICEDIR}"
|
ln -s "${DEST}" "${SERVICEDIR}"
|
||||||
done
|
done
|
||||||
else
|
|
||||||
_log 'debug' "'${DMS_STATE_DIR}' is not present; Not consolidating state"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _setup_adjust_state_permissions() {
|
function _setup_adjust_state_permissions() {
|
||||||
if [[ -d ${DMS_STATE_DIR} ]]; then
|
if [[ ! -d ${DMS_STATE_DIR:?DMS_STATE_DIR is not set} ]]; then
|
||||||
|
_log 'debug' "'${DMS_STATE_DIR}' is not present - not adjusting state permissions"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
# This ensures the user and group of the files from the external mount have their
|
# 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
|
# 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.
|
# can change the values in the Docker image, causing an ownership mismatch.
|
||||||
|
@ -123,5 +124,4 @@ function _setup_adjust_state_permissions() {
|
||||||
# Ref: https://github.com/docker-mailserver/docker-mailserver/pull/3625
|
# Ref: https://github.com/docker-mailserver/docker-mailserver/pull/3625
|
||||||
chmod 730 "${DMS_STATE_DIR}/spool-postfix/maildrop"
|
chmod 730 "${DMS_STATE_DIR}/spool-postfix/maildrop"
|
||||||
chmod 710 "${DMS_STATE_DIR}/spool-postfix/public"
|
chmod 710 "${DMS_STATE_DIR}/spool-postfix/public"
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue