#!/bin/sh
#
# p3scan	p3scan an application level gateway for the POP3 protocol
#
# chkconfig:	345 60 40
#
# description:	p3scan provides transparent antivirus scanner \
#		gateway for the POP3 protocol.
#

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

# Get service config
[ -f /etc/sysconfig/p3scan ] && . /etc/sysconfig/p3scan

RETVAL=0
# See how we were called.
case "$1" in
  start)
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/p3scan ]; then
		msg_starting p3scan
		[ -f /var/run/p3scan/p3scan.pid ] && rm -f /var/run/p3scan/p3scan.pid
		daemon "/usr/sbin/p3scan"
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/p3scan
	else
		msg_already_running p3scan
	fi
	;;
  stop)
	if [ -f /var/lock/subsys/p3scan ]; then
		msg_stopping p3scan
		killproc p3scan
		rm -f /var/run/p3scan/p3scan.pid /var/lock/subsys/p3scan >/dev/null 2>&1
	else
		msg_not_running p3scan
	fi
	;;
  restart|force-reload)
	$0 stop
	$0 start
	exit $?
	;;
  status)
	status p3scan
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
esac

exit $RETVAL
