#!/bin/sh
#
# akpop3d       Starts/stops akpop3d.
#
# chkconfig: 2345 86 14
# description: akpop3d is a POP3 daemon designed to be small and secure.

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

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

PIDFILE1=/var/run/akpop3d.pid
PIDFILE2=/var/run/akpop3d-ssl.pid

RETVAL=0

# See how we were called.
case "$1" in
  start)
	action "Starting POP3 daemon: " /usr/sbin/akpop3d -d -f $PIDFILE1
	RETVAL=$?
	action "Starting SSL POP3 daemon: " /usr/sbin/akpop3d -s -d -f $PIDFILE2
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/akpop3d
	;;
  stop)
	echo -n "Shutting down POP3 daemon: "
	killproc akpop3d-ssl
	killproc akpop3d
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/akpop3d
	;;
  status)
	status akpop3d
	RETVAL=$?
	;;
  restart|reload)
	$0 stop
	$0 start
	RETVAL=$?
	;;
  *)
	echo "Usage: akpop3d {start|stop|status|restart}"
	exit 1
esac

exit $RETVAL
