diff --git a/Dockerfile b/Dockerfile index a6264c63..c0c42ec8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -125,7 +125,7 @@ RUN echo "0 */6 * * * clamav /usr/bin/freshclam --quiet" > /etc/cron.d/clamav-fr # Configures Dovecot COPY target/dovecot/auth-passwdfile.inc target/dovecot/??-*.conf /etc/dovecot/conf.d/ COPY target/dovecot/scripts/quota-warning.sh /usr/local/bin/quota-warning.sh -COPY target/dovecot/sieve/* /usr/lib/dovecot/sieve-global/ +COPY target/dovecot/sieve/ /etc/dovecot/sieve/ WORKDIR /usr/share/dovecot # hadolint ignore=SC2016,SC2086 RUN sed -i -e 's/include_try \/usr\/share\/dovecot\/protocols\.d/include_try \/etc\/dovecot\/protocols\.d/g' /etc/dovecot/dovecot.conf && \ diff --git a/target/dovecot/90-sieve.conf b/target/dovecot/90-sieve.conf index 1c4db02d..78fbe47b 100644 --- a/target/dovecot/90-sieve.conf +++ b/target/dovecot/90-sieve.conf @@ -31,14 +31,14 @@ plugin { # executed. The order of execution within a directory is determined by the # file names, using a normal 8bit per-character comparison. Multiple script # file or directory paths can be specified by appending an increasing number. - #sieve_before = /usr/lib/dovecot/sieve-global/before.dovecot.sieve - #sieve_before2 = /usr/lib/dovecot/sieve-global/before.spam.sieve + sieve_before = /usr/lib/dovecot/sieve-global/before/ + #sieve_before2 = #sieve_before3 = (etc...) # Identical to sieve_before, only the specified scripts are executed after the # user's script (only when keep is still in effect!). Multiple script file or # directory paths can be specified by appending an increasing number. - #sieve_after = /usr/lib/dovecot/sieve-global/after.dovecot.sieve + sieve_after = /usr/lib/dovecot/sieve-global/after/ #sieve_after2 = #sieve_after2 = (etc...) diff --git a/target/dovecot/sieve/before.spam.sieve b/target/dovecot/sieve/before/spam.sieve similarity index 100% rename from target/dovecot/sieve/before.spam.sieve rename to target/dovecot/sieve/before/spam.sieve diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index d688b51d..574860e4 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -614,29 +614,32 @@ function _setup_dovecot() { rm -f /usr/lib/dovecot/sieve-pipe/* [ -d /tmp/docker-mailserver/sieve-filter ] && cp /tmp/docker-mailserver/sieve-filter/* /usr/lib/dovecot/sieve-filter/ [ -d /tmp/docker-mailserver/sieve-pipe ] && cp /tmp/docker-mailserver/sieve-pipe/* /usr/lib/dovecot/sieve-pipe/ + + # create global sieve directories + mkdir -p /usr/lib/dovecot/sieve-global/before + mkdir -p /usr/lib/dovecot/sieve-global/after + if [ -f /tmp/docker-mailserver/before.dovecot.sieve ]; then - sed -i "s/#sieve_before =/sieve_before =/" /etc/dovecot/conf.d/90-sieve.conf - cp /tmp/docker-mailserver/before.dovecot.sieve /usr/lib/dovecot/sieve-global/ - sievec /usr/lib/dovecot/sieve-global/before.dovecot.sieve + cp /tmp/docker-mailserver/before.dovecot.sieve /usr/lib/dovecot/sieve-global/before/ + sievec /usr/lib/dovecot/sieve-global/before/before.dovecot.sieve else - sed -i "s/ sieve_before =/ #sieve_before =/" /etc/dovecot/conf.d/90-sieve.conf + rm -f /usr/lib/dovecot/sieve-global/before/before.dovecot.sieve /usr/lib/dovecot/sieve-global/before/before.dovecot.svbin fi if [ -f /tmp/docker-mailserver/after.dovecot.sieve ]; then - sed -i "s/#sieve_after =/sieve_after =/" /etc/dovecot/conf.d/90-sieve.conf - cp /tmp/docker-mailserver/after.dovecot.sieve /usr/lib/dovecot/sieve-global/ - sievec /usr/lib/dovecot/sieve-global/after.dovecot.sieve + cp /tmp/docker-mailserver/after.dovecot.sieve /usr/lib/dovecot/sieve-global/after/ + sievec /usr/lib/dovecot/sieve-global/after/after.dovecot.sieve else - sed -i "s/ sieve_after =/ #sieve_after =/" /etc/dovecot/conf.d/90-sieve.conf + rm -f /usr/lib/dovecot/sieve-global/after/after.dovecot.sieve /usr/lib/dovecot/sieve-global/after/after.dovecot.svbin fi # sieve will move spams to .Junk folder when SPAMASSASSIN_SPAM_TO_INBOX=1 and MOVE_SPAM_TO_JUNK=1 if [ "$SPAMASSASSIN_SPAM_TO_INBOX" = 1 ] && [ "$MOVE_SPAM_TO_JUNK" = 1 ]; then notify 'inf' "Spam messages will be moved to the Junk folder." - sed -i "s/#sieve_before2 =/sieve_before2 =/" /etc/dovecot/conf.d/90-sieve.conf - sievec /usr/lib/dovecot/sieve-global/before.spam.sieve + cp /etc/dovecot/sieve/before/spam.sieve /usr/lib/dovecot/sieve-global/before/ + sievec /usr/lib/dovecot/sieve-global/before/spam.sieve else - sed -i "s/ sieve_before2 =/ #sieve_before2 =/" /etc/dovecot/conf.d/90-sieve.conf + rm -f /usr/lib/dovecot/sieve-global/before/spam.sieve /usr/lib/dovecot/sieve-global/before/spam.svbin fi chown docker:docker -R /usr/lib/dovecot/sieve*