From b32e5adcc5d6e22fed6eefc94f769073978525e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= Date: Fri, 3 Nov 2017 20:25:38 +0100 Subject: [PATCH] [Dovecot] sieve_before/after maps in sql, changed dict names --- data/Dockerfiles/dovecot/Dockerfile | 12 ++--- data/Dockerfiles/dovecot/docker-entrypoint.sh | 50 ++++++++++++++++++- 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/data/Dockerfiles/dovecot/Dockerfile b/data/Dockerfiles/dovecot/Dockerfile index d7f9cf38..d2cdd0e3 100644 --- a/data/Dockerfiles/dovecot/Dockerfile +++ b/data/Dockerfiles/dovecot/Dockerfile @@ -3,8 +3,8 @@ LABEL maintainer "Andre Peters " ARG DEBIAN_FRONTEND=noninteractive ENV LC_ALL C -ENV DOVECOT_VERSION 2.2.32 -ENV PIGEONHOLE_VERSION 0.4.20 +ENV DOVECOT_VERSION 2.2.33.2 +ENV PIGEONHOLE_VERSION 0.4.21 RUN apt-get update && apt-get -y install \ automake \ @@ -40,10 +40,11 @@ RUN apt-get update && apt-get -y install \ libtest-pod-perl \ libtest-simple-perl \ libunicode-string-perl \ - libproc-processtable-perl \ + libproc-processtable-perl \ liburi-perl \ lzma-dev \ make \ + procps \ supervisor \ syslog-ng \ syslog-ng-core \ @@ -64,7 +65,8 @@ RUN curl https://www.dovecot.org/releases/2.2/dovecot-$DOVECOT_VERSION.tar.gz | && make -j3 \ && make install \ && make clean \ - && cd .. && rm -rf dovecot-2.2-pigeonhole-$PIGEONHOLE_VERSION + && cd .. \ + && rm -rf dovecot-2.2-pigeonhole-$PIGEONHOLE_VERSION RUN cpanm Data::Uniqid Mail::IMAPClient String::Util RUN echo '* * * * * root /usr/local/bin/imapsync_cron.pl' > /etc/cron.d/imapsync @@ -98,8 +100,6 @@ RUN touch /etc/default/locale RUN apt-get purge -y build-essential automake autotools-dev \ && apt-get autoremove --purge -y -EXPOSE 24 10001 - ENTRYPOINT ["/docker-entrypoint.sh"] CMD exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf diff --git a/data/Dockerfiles/dovecot/docker-entrypoint.sh b/data/Dockerfiles/dovecot/docker-entrypoint.sh index 4e9fe14b..9f8f5313 100755 --- a/data/Dockerfiles/dovecot/docker-entrypoint.sh +++ b/data/Dockerfiles/dovecot/docker-entrypoint.sh @@ -15,7 +15,7 @@ sed -i "/^\$DBNAME/c\\\$DBNAME='${DBNAME}';" /usr/local/bin/imapsync_cron.pl DBPASS=$(echo ${DBPASS} | sed 's/"/\\"/g') # Create quota dict for Dovecot -cat < /usr/local/etc/dovecot/sql/dovecot-dict-sql.conf +cat < /usr/local/etc/dovecot/sql/dovecot-dict-sql-quota.conf connect = "host=mysql dbname=${DBNAME} user=${DBUSER} password=${DBPASS}" map { pattern = priv/quota/storage @@ -31,8 +31,54 @@ map { } EOF +# Create dict used for sieve pre and postfilters +cat < /usr/local/etc/dovecot/sql/dovecot-dict-sql-sieve_before.conf +connect = "host=mysql dbname=${DBNAME} user=${DBUSER} password=${DBPASS}" +map { + pattern = priv/sieve/name/\$script_name + table = sieve_before + username_field = username + value_field = id + fields { + script_name = \$script_name + } +} +map { + pattern = priv/sieve/data/\$id + table = sieve_before + username_field = username + value_field = script_data + fields { + id = \$id + } +} +EOF + +cat < /usr/local/etc/dovecot/sql/dovecot-dict-sql-sieve_after.conf +connect = "host=mysql dbname=${DBNAME} user=${DBUSER} password=${DBPASS}" +map { + pattern = priv/sieve/name/\$script_name + table = sieve_after + username_field = username + value_field = id + fields { + script_name = \$script_name + } +} +map { + pattern = priv/sieve/data/\$id + table = sieve_after + username_field = username + value_field = script_data + fields { + id = \$id + } +} +EOF + + # Create user and pass dict for Dovecot -cat < /usr/local/etc/dovecot/sql/dovecot-mysql.conf +cat < /usr/local/etc/dovecot/sql/dovecot-dict-sql-passdb.conf driver = mysql connect = "host=mysql dbname=${DBNAME} user=${DBUSER} password=${DBPASS}" default_pass_scheme = SSHA256