Fix for #552
This commit is contained in:
parent
12f0b5f033
commit
d582d9cee9
|
@ -193,7 +193,7 @@ RUN curl -s https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.pem > /et
|
||||||
|
|
||||||
COPY ./target/bin /usr/local/bin
|
COPY ./target/bin /usr/local/bin
|
||||||
# Start-mailserver script
|
# Start-mailserver script
|
||||||
COPY ./target/start-mailserver.sh ./target/fail2ban-wrapper.sh ./target/postfix-wrapper.sh ./target/docker-configomat/configomat.sh /usr/local/bin/
|
COPY ./target/check_for_changes.sh ./target/start-mailserver.sh ./target/fail2ban-wrapper.sh ./target/postfix-wrapper.sh ./target/docker-configomat/configomat.sh /usr/local/bin/
|
||||||
RUN chmod +x /usr/local/bin/*
|
RUN chmod +x /usr/local/bin/*
|
||||||
|
|
||||||
# Configure supervisor
|
# Configure supervisor
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
while ! [ $ENABLE_LDAP = 1 ]; do
|
||||||
|
|
||||||
|
cd /tmp/docker-mailserver
|
||||||
|
chksum=$(sha512sum -c chksum)
|
||||||
|
resu_acc=${chksum:21:2}
|
||||||
|
resu_vir=${chksum:44:2}
|
||||||
|
|
||||||
|
if ! [ $resu_acc = "OK" ] || ! [ $resu_vir = "OK" ]; then
|
||||||
|
echo "CHANGE DETECT"
|
||||||
|
echo -n > /etc/postfix/vmailbox
|
||||||
|
echo -n > /etc/dovecot/userdb
|
||||||
|
if [ -f /tmp/docker-mailserver/postfix-accounts.cf -a "$ENABLE_LDAP" != 1 ]; then
|
||||||
|
sed -i 's/\r//g' /tmp/docker-mailserver/postfix-accounts.cf
|
||||||
|
echo "# WARNING: this file is auto-generated. Modify config/postfix-accounts.cf to edit user list." > /etc/postfix/vmailbox
|
||||||
|
# Checking that /tmp/docker-mailserver/postfix-accounts.cf ends with a newline
|
||||||
|
sed -i -e '$a\' /tmp/docker-mailserver/postfix-accounts.cf
|
||||||
|
chown dovecot:dovecot /etc/dovecot/userdb
|
||||||
|
chmod 640 /etc/dovecot/userdb
|
||||||
|
sed -i -e '/\!include auth-ldap\.conf\.ext/s/^/#/' /etc/dovecot/conf.d/10-auth.conf
|
||||||
|
sed -i -e '/\!include auth-passwdfile\.inc/s/^#//' /etc/dovecot/conf.d/10-auth.conf
|
||||||
|
# Creating users
|
||||||
|
# 'pass' is encrypted
|
||||||
|
# comments and empty lines are ignored
|
||||||
|
grep -v "^\s*$\|^\s*\#" /tmp/docker-mailserver/postfix-accounts.cf | while IFS=$'|' read login pass
|
||||||
|
do
|
||||||
|
# Setting variables for better readability
|
||||||
|
user=$(echo ${login} | cut -d @ -f1)
|
||||||
|
domain=$(echo ${login} | cut -d @ -f2)
|
||||||
|
# Let's go!
|
||||||
|
echo "${login} ${domain}/${user}/" >> /etc/postfix/vmailbox
|
||||||
|
# User database for dovecot has the following format:
|
||||||
|
# user:password:uid:gid:(gecos):home:(shell):extra_fields
|
||||||
|
# Example :
|
||||||
|
# ${login}:${pass}:5000:5000::/var/mail/${domain}/${user}::userdb_mail=maildir:/var/mail/${domain}/${user}
|
||||||
|
echo "${login}:${pass}:5000:5000::/var/mail/${domain}/${user}::" >> /etc/dovecot/userdb
|
||||||
|
mkdir -p /var/mail/${domain}
|
||||||
|
if [ ! -d "/var/mail/${domain}/${user}" ]; then
|
||||||
|
maildirmake.dovecot "/var/mail/${domain}/${user}"
|
||||||
|
maildirmake.dovecot "/var/mail/${domain}/${user}/.Sent"
|
||||||
|
maildirmake.dovecot "/var/mail/${domain}/${user}/.Trash"
|
||||||
|
maildirmake.dovecot "/var/mail/${domain}/${user}/.Drafts"
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
if [ -f /tmp/vhost.tmp ]; then
|
||||||
|
cat /tmp/vhost.tmp | sort | uniq > /etc/postfix/vhost && rm /tmp/vhost.tmp
|
||||||
|
fi
|
||||||
|
if [ `find /var/mail -maxdepth 3 -a \( \! -user 5000 -o \! -group 5000 \) | grep -c .` != 0 ]; then
|
||||||
|
chown -R 5000:5000 /var/mail
|
||||||
|
fi
|
||||||
|
|
||||||
|
postfix reload
|
||||||
|
dovecot reload
|
||||||
|
sha512sum --tag postfix-accounts.cf --tag postfix-virtual.cf > chksum
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
|
@ -1243,7 +1243,11 @@ function _start_daemons_amavis() {
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# Start check for update postfix-accounts and postfix-virtual
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
nohup /usr/local/bin/check_for_changes.sh >/dev/null 2>&1 &
|
||||||
|
|
||||||
|
|
||||||
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
Loading…
Reference in New Issue