mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
fix: Only add state of enabled services for volume mount (#2608)
* fix: Conditionally add service state These services will no longer copy over state unless they are enabled. The biggest offender here was ClamAV as it's database that is baked into the docker image is over 200MB and would copy over to every container instance with a volume mounted state directory. * chore: Add Dovecot to conditional support
This commit is contained in:
parent
c862e1451d
commit
d04aceccae
|
@ -24,14 +24,17 @@ function _misc_save_states
|
|||
FILES=(
|
||||
spool/postfix
|
||||
lib/postfix
|
||||
lib/amavis
|
||||
lib/clamav
|
||||
lib/spamassassin
|
||||
lib/fail2ban
|
||||
lib/postgrey
|
||||
lib/dovecot
|
||||
)
|
||||
|
||||
# Only consolidate state for services that are enabled
|
||||
# Notably avoids copying over 200MB for the ClamAV database
|
||||
[[ ${ENABLE_AMAVIS} -eq 1 ]] && FILES+=('lib/amavis')
|
||||
[[ ${ENABLE_CLAMAV} -eq 1 ]] && FILES+=('lib/clamav')
|
||||
[[ ${ENABLE_FAIL2BAN} -eq 1 ]] && FILES+=('lib/fail2ban')
|
||||
[[ ${ENABLE_SPAMASSASSIN} -eq 1 ]] && FILES+=('lib/spamassassin')
|
||||
[[ ${ENABLE_POSTGREY} -eq 1 ]] && FILES+=('lib/postgrey')
|
||||
[[ ${SMTP_ONLY} -ne 1 ]] && FILES+=('lib/dovecot')
|
||||
|
||||
for FILE in "${FILES[@]}"
|
||||
do
|
||||
DEST="${STATEDIR}/${FILE//\//-}"
|
||||
|
@ -55,10 +58,11 @@ function _misc_save_states
|
|||
done
|
||||
|
||||
_log 'trace' 'Fixing /var/mail-state/* permissions'
|
||||
chown -R clamav /var/mail-state/lib-clamav
|
||||
[[ ${ENABLE_CLAMAV} -eq 1 ]] && chown -R clamav /var/mail-state/lib-clamav
|
||||
[[ ${ENABLE_SPAMASSASSIN} -eq 1 ]] && chown -R debian-spamd /var/mail-state/lib-spamassassin
|
||||
[[ ${ENABLE_POSTGREY} -eq 1 ]] && chown -R postgrey /var/mail-state/lib-postgrey
|
||||
|
||||
chown -R postfix /var/mail-state/lib-postfix
|
||||
chown -R postgrey /var/mail-state/lib-postgrey
|
||||
chown -R debian-spamd /var/mail-state/lib-spamassassin
|
||||
|
||||
# UID = postfix(101): active, bounce, corrupt, defer, deferred, flush, hold, incoming, maildrop, private, public, saved, trace
|
||||
# UID = root(0): dev, etc, lib, pid, usr
|
||||
|
|
Loading…
Reference in a new issue