PREIN
/bin/sh
#dovecot uid 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
# do not let dovecot run during upgrade rhbz#134325
if [ "$1" = "2" ]; then
rm -f /var/run/dovecot/dovecot-restart-after-rpm-install
/bin/systemctl is-active dovecot.service >/dev/null 2>&1 && touch /var/run/dovecot/dovecot-restart-after-rpm-install ||:
/bin/systemctl stop dovecot.service >/dev/null 2>&1
fi
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
if [ $1 -eq 1 ] ; then
# Initial installation
systemctl preset dovecot.service >/dev/null 2>&1 || :
fi
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
POSTUN
/bin/sh
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ "$1" -ge "1" -a -e /var/run/dovecot/dovecot-restart-after-rpm-install ]; then
/bin/systemctl start dovecot.service >/dev/null 2>&1 || :
rm -f /var/run/dovecot/dovecot-restart-after-rpm-install
fi
POSTTRANS
/bin/sh
# dovecot should be started again in %postun, but it's not executed on reinstall
# if it was already started, restart_flag won't be here, so it's ok to test it again
if [ -e /var/run/dovecot/dovecot-restart-after-rpm-install ]; then
/bin/systemctl start dovecot.service >/dev/null 2>&1 || :
rm -f /var/run/dovecot/dovecot-restart-after-rpm-install
fi