Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > media > main-release > by-pkgid > 178f550de59964a3be8a0da0f7c52c2d > scriptlet

cyrus-imapd-2.3.15-7mdv2010.1.x86_64.rpm

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
/usr/share/rpm-helper/del-service cyrus-imapd $1 cyrus-imapd 
if [ $1 = 0 ]; then
	/usr/sbin/userdel cyrus 2> /dev/null || :
	rm -f /var/lib/imap/socket/lmtp 2> /dev/null
	rm -f /var/lib/imap/rpm/version 2> /dev/null
fi

POSTIN

/bin/sh
if [ $1 = 1 ] ; then

# make sure we own the stuff, otherwise /var/log/mail/* will fill
# the whole disk with error messages...
chown -R cyrus:mail /var/lib/imap /var/spool/imap

  #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

# upgrade from previous versions with compiled in database backends
rm -f /var/lib/imap/rpm/db.cfg.cache 2> /dev/null

# "ctl_deliver -E" is deprecated, now is "cyr_expire -E"
if grep -q "ctl_deliver *-E" /etc/cyrus.conf ; then
  perl -pi -e "s/ctl_deliver *-E/cyr_expire -E/" /etc/cyrus.conf
fi
# compile to byte code sieve scripts on upgrade
# masssievec needs to run:
# - for versions before 2.2.0 (2.1.x) since they had no bytecode
# - upgrading from 2.2.0 since the bytecode has changed
# - upgrading from 2.2.1 since the bytecode has changed
if [ $1 != 1 ] ; then 
  if [ -f /var/lib/imap/rpm/version ] ; then
    oldversion=`cat /var/lib/imap/rpm/version`
    if [ "$oldversion" = "2.2.0" -o "$oldversion" = "2.2.1" ] ; then
      compile_needed=1
    else
      compile_needed=0
    fi
  else
    # versions prior to 2.2.x didn't write the file
    compile_needed=1
  fi
  if [ $compile_needed = 1 ] ; then
    echo "compiling sieve scripts"
    su cyrus -c "/usr/lib/cyrus-imapd/masssievec /usr/lib/cyrus-imapd/sievec"
  fi
fi
# cache the installed version for next upgrade
echo 2.3.15 > /var/lib/imap/rpm/version

/usr/share/rpm-helper/add-service cyrus-imapd $1 cyrus-imapd

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 || :