cda8379
#!/bin/bash
cda8379
#
cda8379
# exim    This shell script takes care of starting and stopping exim
cda8379
#
cda8379
# chkconfig: 2345 80 30
cda8379
# description: Exim is a Mail Transport Agent, which is the program \
cda8379
#              that moves mail from one machine to another.
cda8379
# processname: exim
cda8379
# config: /etc/exim/exim.conf
cda8379
# pidfile: /var/run/exim.pid
cda8379
cda8379
# Source function library.
cda8379
. /etc/init.d/functions
cda8379
cda8379
# Source networking configuration.
cda8379
. /etc/sysconfig/network
cda8379
cda8379
# Source exim configureation.
cda8379
if [ -f /etc/sysconfig/exim ] ; then
cda8379
	. /etc/sysconfig/exim
cda8379
else
cda8379
	DAEMON=yes
cda8379
	QUEUE=1h
cda8379
fi
cda8379
cda8379
# Check that networking is up.
cda8379
[ ${NETWORKING} = "no" ] && exit 0
cda8379
cda8379
[ -f /usr/sbin/exim ] || exit 0
cda8379
cda8379
start() {
cda8379
	# check ownerships
cda8379
	# do this by seeing if /var/log/exim/main.log exists and is
cda8379
	# owned by exim - if owned by someone else we fix it up
cda8379
	if [ -f /var/log/exim/main.log ]
cda8379
	then
cda8379
	    if [ "exim" != "`ls -l /var/log/exim/main.log | awk '{print $4}'`" ]
cda8379
	    then
cda8379
		chown -R exim:exim /var/log/exim /var/spool/exim
cda8379
	    fi
cda8379
	fi
cda8379
        # Start daemons.
cda8379
        echo -n $"Starting exim: "
cda8379
        daemon /usr/sbin/exim $([ "$DAEMON" = yes ] && echo -bd) \
cda8379
                              $([ -n "$QUEUE" ] && echo -q$QUEUE)
cda8379
        RETVAL=$?
cda8379
        echo
cda8379
        [ $RETVAL = 0 ] && touch /var/lock/subsys/exim
cda8379
}
cda8379
cda8379
stop() {
cda8379
        # Stop daemons.
cda8379
        echo -n $"Shutting down exim: "
cda8379
        killproc exim
cda8379
	RETVAL=$?
cda8379
        echo
cda8379
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/exim
cda8379
}
cda8379
cda8379
restart() {
cda8379
	stop
cda8379
	start
cda8379
}
cda8379
cda8379
# See how we were called.
cda8379
case "$1" in
cda8379
  start)
cda8379
	start
cda8379
	;;
cda8379
  stop)
cda8379
	stop
cda8379
	;;
cda8379
  restart)
cda8379
	restart
cda8379
	;;
cda8379
  condrestart)
cda8379
 	[ -f /var/lock/subsys/exim ] && restart || :
cda8379
	;;
cda8379
  status)
cda8379
	status exim
cda8379
	;;
cda8379
  *)
cda8379
	echo $"Usage: $0 {start|stop|restart|status|condrestart}"
cda8379
	exit 1
cda8379
esac
cda8379
cda8379
exit $RETVAL
cda8379