PREIN
/bin/sh
#dovecot uig and gid are reserved, see /usr/share/doc/setup-*/uidgid
getent group dovecot >/dev/null || groupadd -r --gid 97 dovecot
getent passwd dovecot >/dev/null || \
useradd -r --uid 97 -g dovecot -d /usr/libexec/dovecot -s /sbin/nologin -c "Dovecot IMAP server" dovecot
getent group dovenull >/dev/null || groupadd -r dovenull
getent passwd dovenull >/dev/null || \
useradd -r -g dovenull -d /usr/libexec/dovecot -s /sbin/nologin -c "Dovecot's unauthorized user" dovenull
exit 0
PREUN
/bin/sh
if [ $1 = 0 ]; then
/bin/systemctl disable dovecot.service dovecot.socket >/dev/null 2>&1 || :
/bin/systemctl stop dovecot.service dovecot.socket >/dev/null 2>&1 || :
rm -rf /var/run/dovecot
fi
POSTIN
/bin/sh
if [ $1 -eq 1 ]
then
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi
# generate the ssl certificates
if [ ! -f /etc/pki/dovecot/certs/dovecot.pem ]; then
SSLDIR=/etc/pki/dovecot OPENSSLCONFIG=/etc/pki/dovecot/dovecot-openssl.cnf \
/usr/libexec/dovecot/mkcert.sh &> /dev/null
fi
if [ ! -f /var/lib/dovecot/ssl-parameters.dat ]; then
/usr/libexec/dovecot/ssl-params &>/dev/null
fi
install -d -m 0755 -g dovecot -d /var/run/dovecot
install -d -m 0755 -d /var/run/dovecot/empty
install -d -m 0750 -g dovenull /var/run/dovecot/login
[ -x /sbin/restorecon ] && /sbin/restorecon -R /var/run/dovecot
exit 0
POSTUN
/bin/sh
if [ "$1" -ge "1" ]; then
/bin/systemctl try-restart dovecot.service >/dev/null 2>&1 || :
fi