Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > 469eeb92207928b5420d9ef217b70747 > files > 7

cyrus-imapd-2.1.12-5mdk.ppc.rpm


#!/bin/sh
#
# chkconfig: 2345 65 35
# description: The Cyrus IMAPD master serves as a master process for the Cyrus \
#              IMAP and POP servers.
# config: /etc/cyrus.conf
# config: /etc/imapd.conf

# Author:       Simon Matter <simix@datacomm.ch>
# Version:	2002011900
# changed:	2002020200 chkconfig modified
#               2002042500 rewrote start function
# Modified for Mandrake by Luca Olivetti <luca@olivetti.cjb.net>
#               2003020400 using new -p -d options to start master

# Source function library
if [ -f /etc/init.d/functions ]; then
  . /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ]; then
  . /etc/rc.d/init.d/functions
else
  exit 0
fi

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

# check if the config files are present
[ -f /etc/cyrus.conf ] || exit 0
[ -f /etc/imapd.conf ] || exit 0
 
# This is our service name
BASENAME=`basename $0`
if [ -L $0 ]; then
  BASENAME=`find $0 -name $BASENAME -printf %l`
  BASENAME=`basename $BASENAME`
fi
 
# Source service configuration.
if [ -f /etc/sysconfig/$BASENAME ]; then
  . /etc/sysconfig/$BASENAME
else
  gprintf "%s: configfile /etc/sysconfig/%s does NOT exist !\n" "$BASENAME" "$BASENAME"
  exit 1
fi

CYRUSMASTER=/usr/lib/cyrus/cyrus-master
CYRUS_PROC_NAME=`basename $CYRUSMASTER`
CYRUS_STARTUP_TIMEOUT=20
DB_CFG=/usr/share/cyrus-imapd/rpm/db.cfg
DB_CFG_CACHE=/var/lib/imap/rpm/db.cfg.cache


RETVAL=0

start() {
  gprintf "Starting %s: " "$BASENAME"
  if [ ! `/sbin/pidof -s $CYRUSMASTER` ]; then
    cmp -s $DB_CFG $DB_CFG_CACHE && CONVERT_NEEDED=0 || CONVERT_NEEDED=1
    if [ $CONVERT_NEEDED -eq 1 ] ; then
      echo
      gprintf "db backends configured in this package do not match your system.\n"
      echo
      gprintf "package configuration (in %s):\n" "$DB_CFG"
      cat $DB_CFG
      echo
      gprintf "your system configuration (in %s):\n" "$DB_CFG_CACHE"
      if [ -f  $DB_CFG_CACHE ] ; then
        cat $DB_CFG_CACHE
      else
        gprintf "file not present\n"
      fi
      echo
      gprintf "BACKUP your spool directory and run the conversion utility\n"
      gprintf "/usr/lib/cyrus/cvt_cyrusdb_all.\n"
      gprintf "If you are sure that the package configuration matches your system\n"
      gprintf "and this message is erroneus (for example if you just upgraded the\n"
      gprintf "rpm and there is no %s file in place\n" "$DB_CFG_CACHE"
      gprintf "but you are SURE that the configuration is correct), you can just copy\n"
      gprintf "%s to %s and restart.\n" "$DB_CFG" "$DB_CFG_CACHE"
      RETVAL=1
      return $RETVAL
    fi   
    $CYRUSMASTER $CYRUSOPTIONS -p /var/run/${CYRUS_PROC_NAME}.pid -d
  fi
  RETVAL=$?
  action "" [ $RETVAL -eq 0 ]
  [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$BASENAME \
    || rm -f /var/run/${CYRUS_PROC_NAME}.pid
  return $RETVAL
}

stop() {
  gprintf "Shutting down %s: " "$BASENAME"
  killproc $CYRUSMASTER
  RETVAL=$?
  [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$BASENAME
  echo
  return $RETVAL
}

restart() {
  stop
  start
}

reload() {
  gprintf "Reloading cyrus.conf file: "
  killproc $CYRUSMASTER -HUP
  RETVAL=$?
  echo
  return $RETVAL
}
 
condrestart() {
  [ -e /var/lock/subsys/$BASENAME ] && restart || :
}

rhstatus() {
  status $CYRUSMASTER
}

case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart)
    restart
    ;;
  reload)
    reload
    ;;
  condrestart)
    condrestart
    ;;
  status)
    rhstatus
    ;;
  *)
    gprintf "Usage: %s {start|stop|restart|reload|condrestart|status}\n" "$BASENAME"
    RETVAL=1
esac

exit $RETVAL