PREIN
/bin/sh
# Create 'cyrus' user on target host
/usr/sbin/groupadd -g 76 -r saslauth 2> /dev/null || :
/usr/sbin/useradd -c "Cyrus IMAP Server" -d /var/lib/imap -g mail \
-G saslauth -s /sbin/nologin -u 76 -r cyrus 2> /dev/null || :
PREUN
/bin/sh
if [ $1 = 0 ]; then
/sbin/service cyrus-imapd stop >/dev/null 2>&1 || :
/sbin/chkconfig --del cyrus-imapd
fi
POSTIN
/bin/sh
/sbin/chkconfig --add cyrus-imapd
# Force synchronous updates, usually only on ext2 filesystems
for i in /var/lib/imap/{user,quota} /var/spool/imap
do
if [ "$(find $i -maxdepth 0 -printf %F)" = "ext2" ]; then
chattr -R +S $i 2>/dev/null ||:
fi
done
# Create SSL certificates
exec > /dev/null 2> /dev/null
if [ ! -f /etc/pki/cyrus-imapd/cyrus-imapd.pem ]; then
pushd /etc/pki/tls/certs
umask 077
cat << EOF | make cyrus-imapd.pem
--
SomeState
SomeCity
SomeOrganization
SomeOrganizationalUnit
localhost.localdomain
root@localhost.localdomain
EOF
chown root.mail cyrus-imapd.pem
chmod 640 cyrus-imapd.pem
mv cyrus-imapd.pem /etc/pki/cyrus-imapd/cyrus-imapd.pem
popd
fi
POSTUN
/bin/sh
if [ $1 != 0 ]; then
/sbin/service cyrus-imapd condrestart >/dev/null 2>&1 || :
fi