1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
#!/bin/sh
set -e
if [ "$1" = "configure" ]; then
CONFFILES="dovecot.conf \
conf.d/10-auth.conf \
conf.d/10-logging.conf \
conf.d/10-mail.conf \
conf.d/10-master.conf \
conf.d/10-metrics.conf \
conf.d/10-ssl.conf \
conf.d/15-lda.conf \
conf.d/15-mailboxes.conf \
conf.d/30-dict-server.conf \
conf.d/90-acl.conf \
conf.d/90-fts.conf \
conf.d/90-quota.conf \
conf.d/auth-deny.conf.ext \
conf.d/auth-master.conf.ext \
conf.d/auth-oauth2.conf.ext \
conf.d/auth-passwdfile.conf.ext \
conf.d/auth-sql.conf.ext \
conf.d/auth-static.conf.ext \
conf.d/auth-system.conf.ext"
OLD_CONFFILES="conf.d/auth-vpopmail.conf.ext \
dovecot-dict-auth.conf.ext \
dovecot-dict-sql.conf.ext \
dovecot-sql.conf.ext \
conf.d/10-director.conf \
conf.d/10-tcpwrapper.conf \
conf.d/90-plugin.conf"
## Users
#
adduser --system --group --home /usr/lib/dovecot --gecos "Dovecot mail server" \
--no-create-home --disabled-password --quiet dovecot || true
adduser --system --group --home /nonexistent --no-create-home --gecos "Dovecot login user" \
--disabled-password --quiet dovenull || true
for conffile in $CONFFILES ; do
# Tell ucf that the file in /usr/share/dovecot is the latest
# maintainer version, and let it handle how to manage the real
# configuration file in /etc/dovecot.
ucf --three-way "/usr/share/dovecot/$conffile" "/etc/dovecot/$conffile"
ucfr dovecot-core "/etc/dovecot/$conffile"
if [ "$conffile" != "dovecot.conf" ] && [ -f "/etc/dovecot/$conffile" ] &&
[ "$(echo "$conffile" | cut -b -7)" != "conf.d/" ]; then
chmod 0640 "/etc/dovecot/$conffile"
chgrp dovecot "/etc/dovecot/$conffile"
fi
done
for oldconffile in $OLD_CONFFILES ; do
if [ -e "/etc/dovecot/$oldconffile" ]; then
modified=$(ucfq -w /etc/dovecot/$oldconffile | cut -d: -f4)
if [ "$modified" = "No" ]; then
echo "Removing unmodified obsolete configuration file '/etc/dovecot/$oldconffile'"
rm -f "/etc/dovecot/$oldconffile"
else
echo "Locally modified configuration file '/etc/dovecot/$oldconffile' is obsolete. Please remove."
fi
ucf --purge "/etc/dovecot/$oldconffile"
ucfr --purge dovecot-core "/etc/dovecot/$oldconffile"
fi
done
if ! dpkg-statoverride --list /etc/dovecot/private >/dev/null; then
dpkg-statoverride --quiet --update --add root root 0700 /etc/dovecot/private
fi
# SSL configuration
# Use the ssl-cert-snakeoil certificate in the following cases:
# - On new installations
if [ -z "$2" ]; then
if [ ! -e /etc/dovecot/private/dovecot.key ] && \
[ ! -e /etc/dovecot/private/dovecot.pem ] && \
[ -e /etc/ssl/certs/ssl-cert-snakeoil.pem ] && \
[ -e /etc/ssl/private/ssl-cert-snakeoil.key ]; then
ln -s /etc/ssl/certs/ssl-cert-snakeoil.pem /etc/dovecot/private/dovecot.pem
ln -s /etc/ssl/private/ssl-cert-snakeoil.key /etc/dovecot/private/dovecot.key
fi
fi
fi
if [ "$1" = "triggered" ]; then
if [ -x "/etc/init.d/dovecot" ]; then
invoke-rc.d dovecot restart
fi
fi
#DEBHELPER#
|