#!/bin/sh
#
# Startup script for the Clapf AntiVirus/AntiSpam Daemon
#
# chkconfig: 2345 61 39
# description: Clapf AntiVirus/AntiSpam Daemon is a TCP/IP or socket protocol \
#              server.
# processname: clapf
# pidfile: /var/run/clapf/clapf.pid
# config: /etc/clapf.conf

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

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

OPTIONS="-d "

[ -x /usr/sbin/clapf ] || exit 0

# See how we were called.
case "$1" in
  start)
	echo -n "Starting Clapf AntiVirus/AntiSpam Daemon: "
	daemon clapf $OPTIONS
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/clapf
	;;
  stop)
	echo -n "Stopping Clapf AntiVirus/AntiSpam Daemon: "
	killproc clapf
	rm -f /var/run/clapf/clapf.pid
	RETVAL=$?
	echo
### heres the fix... we gotta remove the stale files on restart
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/clapf 	
	;;
  status)
	status clapf
	RETVAL=$?
	;;
  restart|reload)
	$0 stop
	$0 start
	RETVAL=$?
	;;
  condrestart)
	[ -e /var/lock/subsys/clapf ] && restart
	RETVAL=$?
	;;
  *)
	echo "Usage: clapf {start|stop|status|restart|reload|condrestart}"
	exit 1
esac

exit $RETVAL

