#!/bin/sh
#
# monkey	monkey  
#
# chkconfig:	2345 95 5
#
# description:	monkey WebServer daemon
#
# $Id: monkeyd.init,v 1.5 2003/07/07 00:22:47 ankry Exp $

# 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
		# nls "ERROR: Networking is down. %s can't be run." <service>
		msg_network_down monkey
		exit 1
	fi
else
	exit 0
fi

RETVAL=0
case "$1" in
  start)
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/monkey ]; then
		# show "Starting %s service" monkey
		msg_starting monkey
		daemon monkey -D
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/monkey
	else
		# show "%s service is already running." monkey
		msg_already_running monkey
	fi
	;;
  stop)
	if [ -f /var/lock/subsys/monkey ]; then
		# Stop daemons.
		# show "Stopping %s service" monkey
		msg_stopping monkey
		killproc monkey
		rm -f /var/lock/subsys/monkey
	else
		# show "%s service is not running." monkey
		msg_not_running monkey
	fi
	;;
  status)
	status monkey
	exit $?
	;;
  restart|force-reload)
	$0 stop
	$0 start
	exit $?
	;;
  *)
	# show "Usage: %s {start|stop|restart|force-reload|status}"
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
esac

exit $RETVAL

# This must be last line !
# vi:syntax=sh:tw=78:ts=8:sw=4
