From 25406949ee4bea3a42ece0a6d42b06da428e271e Mon Sep 17 00:00:00 2001 From: angus Date: Fri, 29 Apr 2016 00:41:48 +0200 Subject: [PATCH] Sieve filters can now be installed at user setup. Changed Dockerfile to include a missing configuration file for dovecot (mailboxes). Moved Postfix setup after DKIM/DMARC/SSL setup, near the override postfix setup. --- Dockerfile | 2 +- target/start-mailserver.sh | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 74a9fdf0..eb0cda71 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update -q --fix-missing && \ RUN sed -i -e 's/include_try \/usr\/share\/dovecot\/protocols\.d/include_try \/etc\/dovecot\/protocols\.d/g' /etc/dovecot/dovecot.conf RUN sed -i -e 's/#mail_plugins = \$mail_plugins/mail_plugins = \$mail_plugins sieve/g' /etc/dovecot/conf.d/15-lda.conf ADD target/dovecot/auth-passwdfile.inc /etc/dovecot/conf.d/ -ADD target/dovecot/10-*.conf /etc/dovecot/conf.d/ +ADD target/dovecot/??-*.conf /etc/dovecot/conf.d/ # Enables Spamassassin and CRON updates RUN sed -i -r 's/^(CRON|ENABLED)=0/\1=1/g' /etc/default/spamassassin diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index 223ab9d8..e2ac8b22 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -52,6 +52,8 @@ if [ -f /tmp/docker-mailserver/postfix-accounts.cf ]; then echo -e "INBOX\nSent\nTrash\nDrafts" >> "/var/mail/${domain}/${user}/subscriptions" touch "/var/mail/${domain}/${user}/.Sent/maildirfolder" fi + # Copy user provided sieve file, if present + test -e /tmp/docker-mailserver/${login}.dovecot.sieve && cp /tmp/docker-mailserver/${login}.dovecot.sieve /var/mail/${domain}/${user}/.dovecot.sieve echo ${domain} >> /tmp/vhost.tmp done < /tmp/docker-mailserver/postfix-accounts.cf else @@ -76,14 +78,6 @@ else echo "==> Warning: 'config/postfix-virtual.cf' is not provided. No mail alias/forward created." fi -if [ -f /tmp/vhost.tmp ]; then - cat /tmp/vhost.tmp | sort | uniq > /etc/postfix/vhost && rm /tmp/vhost.tmp -fi - -echo "Postfix configurations" -touch /etc/postfix/vmailbox && postmap /etc/postfix/vmailbox -touch /etc/postfix/virtual && postmap /etc/postfix/virtual - # DKIM # Check if keys are already available if [ -e "/tmp/docker-mailserver/opendkim/KeyTable" ]; then @@ -190,6 +184,14 @@ case $SSL_TYPE in esac +if [ -f /tmp/vhost.tmp ]; then + cat /tmp/vhost.tmp | sort | uniq > /etc/postfix/vhost && rm /tmp/vhost.tmp +fi + +echo "Postfix configurations" +touch /etc/postfix/vmailbox && postmap /etc/postfix/vmailbox +touch /etc/postfix/virtual && postmap /etc/postfix/virtual + # # Override Postfix configuration # @@ -199,7 +201,7 @@ if [ -f /tmp/docker-mailserver/postfix-main.cf ]; then done < /tmp/docker-mailserver/postfix-main.cf echo "Loaded 'config/postfix-main.cf'" else - echo "No extra postfix settings loaded because optional '/tmp/docker-mailserver/main.cf' not provided." + echo "No extra postfix settings loaded because optional '/tmp/docker-mailserver/postfix-main.cf' not provided." fi if [ ! -z "$SASL_PASSWD" ]; then