#!/bin/sh
#
# wccpd		Startup script for the WCCP Server Daemon
#
# chkconfig:	2345 85 15
# description:	WCCP is the Web Cache Coordination Protocol
# processname:	wccpd
#
# pidfile:	/var/run/wccpd.pid
# config:	/etc/sysconfig/wccpd

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

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

# Check that networking is up.
if is_yes "${NETWORKING}"; then
	if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
		msg_network_down arpd
		exit 1
	fi
else
	exit 0
fi

# Source additional OPTIONS if we have them.
if [ -f /etc/sysconfig/wccpd ]; then
	. /etc/sysconfig/wccpd
fi

RETVAL=0
# See how we were called.
case "$1" in
  start)
  	# Start daemons.
	if [ ! -f /var/lock/subsys/wccpd ]; then
		msg_starting wccpd
		daemon wccpd $WCCPD_OPTS
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/wccpd
	else
		msg_already_running wccpd
	fi
	;;
  stop)
	if [ -f /var/lock/subsys/wccpd ]; then
		# Stop daemons.
		msg_stopping wccpd
		killproc wccpd
		rm -f /var/lock/subsys/wccpd >/dev/null 2>&1
	else
		msg_not_running wccpd
	fi
	;;
  restart|force-reload)
  	$0 stop
	nls -n "Waiting %s seconds..." 5
	sleep 5
	nls "done."
	$0 start
	exit $?
	;;
  status)
	status wccpd
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
esac

exit $RETVAL
