sieve after/before use folder instead of individual listing

Loading sieve scripts using a directory scheme permits to handle multi scripts wtihout defining individual sieve_before/sieve_after
This commit is contained in:
youtous 2020-05-04 00:24:10 +02:00
parent a12cd9a26d
commit 92414b7eba
No known key found for this signature in database
GPG key ID: 592173AE8CD254A5
4 changed files with 18 additions and 15 deletions

View file

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

View file

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

View file

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