#! /bin/sh
#
# skeleton	example file to build /etc/init.d/ scripts.
#		This file should be used to construct scripts for /etc/init.d.
#
#		Written by Miquel van Smoorenburg <miquels@cistron.nl>.
#		Modified for Debian 
#		by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Version:	@(#)skeleton  1.9  26-Feb-2001  miquels@cistron.nl
#

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/cherokee
NAME=cherokee

test -x $DAEMON || exit 0

PIDFILE=`grep -i '^PidFile' /etc/cherokee/cherokee.conf | sed -e 's/pidfile[\t ]\+//i'`
if [ "x$PIDFILE" = "x" ];
then
        PIDFILE=/var/run/cherokee.pid
fi

set -e


case "$1" in
  start)	
	echo -n "Starting web server: $NAME"
	start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON -b
	;;

  stop)
	echo -n "Stopping web server: $NAME"
	start-stop-daemon --stop --oknodo --pidfile $PIDFILE --exec $DAEMON
	;;

  restart)
	$0 stop
     sleep 1
     $0 start
	;;

  reload|force-reload)
	start-stop-daemon --stop --signal HUP --pidfile $PIDFILE --name $NAME
	;;

  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	exit 1
	;;
esac

if [ $? == 0 ]; then
        echo .
        exit 0
else
        echo failed
        exit 1
fi

exit 0
