PREIN
/bin/sh
# Create 'cyrus' user on target host
/usr/sbin/useradd -c "Cyrus IMAP Server" -d /var/lib/imap -g mail \
-s /bin/bash -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
/usr/sbin/userdel cyrus 2> /dev/null || :
rm -f /var/lib/imap/socket/lmtp 2> /dev/null
rm -f /var/lib/imap/rpm/db.cfg.cache 2> /dev/null
fi
POSTIN
/bin/sh
/sbin/chkconfig --add cyrus-imapd
if [ $1 = 1 ] ; then
#Create a self-signed server key and certificate
#The script checks first if they exists, if yes, it exits,
#otherwise, it creates them.
if ! [ -f /etc/ssl/cyrus-imapd/cyrus-imapd.pem ];then
sh /usr/lib/cyrus-imapd/mkimapdcert >/dev/null
fi
fi
# Force synchronous updates only on ext2 filesystems
# Note: This will slow down user creation for 10.000+ users!
for i in /var/lib/imap/{user,quota} /var/spool/imap
do
if [ `find $i -maxdepth 0 -printf file.file` = "ext2" ]; then
chattr -R +S $i 2>/dev/null
fi
done
# Add sieve service if necessary
if ! grep -q ^sieve /etc/services; then
echo -e 'sieve\t\t2000/tcp\t\t\t# Sieve mail filter daemon' >> /etc/services
fi
# Add lmtp service if necessary
if ! grep -q ^lmtp /etc/services; then
echo -e 'lmtp\t\t2003/tcp\t\t\t# Local mail delivery protocol (rfc2033)' >> /etc/services
fi
# copy the db config file if conf directory is clean (no mailboxes.db)
if [ $1 = 1 ]; then
if [ -f /var/lib/imap/mailboxes.db ] ; then
cat<<EOF
This is the first time that this package is being installed
but there's an existing /var/lib/imap/mailboxes.db file so
it's not possible to know if the current configuration of the
various cyrus databases corresponds to the compiled in options.
Please BACK UP your configuration and spool directory and run
the /usr/lib/cyrus-imapd/cvt_cyrusdb_all utility.
EOF
else
cp -f /usr/share/cyrus-imapd/rpm/db.cfg /var/lib/imap/rpm/db.cfg.cache
fi
echo "Remember to assign a password to user cyrus in order"
echo "to administer the server."
fi
POSTUN
/bin/sh
if [ $1 -ge 1 ]; then
/sbin/service cyrus-imapd condrestart >/dev/null 2>&1 || :
fi
Triggers
cyrus-imapd <
2.0.0
/bin/sh
#To avoid automatic restart of the daemon when upgrading from versions
#1.x.x of Cyrus IMAPd in rpm form, be sure the old daemon is stopped
/sbin/service cyrus-imapd stop >/dev/null 2>&1 || :