#!/bin/sh
#
# chkconfig: 345 80 75
# description: PowerIMAP makes email available using the imap4 \
# protocol. 
# probe: false
# processname: powerimap
# pidfile: /var/run/powermail/powerimap.pid
# config: /etc/powermail/powerimap.conf

# Source function library.
. /etc/rc.d/init.d/functions

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

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

[ -f /etc/powermail/powerimap.conf ] || exit 0

[ -f /usr/sbin/powerimap ] || exit 0

# See how we were called.
case "$1" in
  start)
	echo -n "Starting PowerIMAP: "
	/usr/sbin/powerimap start
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/powerimap
	;;
  stop)
	echo -n "Stopping PowerIMAP: "
	/usr/sbin/powerimap stop
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/powerimap
	;;
  monitor)
	/usr/sbin/powerimap --daemon=no --loglevel=9
	;;
  status)
	status powerimap
	RETVAL=$?
	;;
  restart|reload)
	$0 stop
	$0 start
	RETVAL=$?
	;;
  *)
	echo "Usage: powerimap {start|stop|monitor|status|restart|reload}"
	exit 1
esac

exit $RETVAL
