#!/bin/sh
#
# cherokee:       Starts the cherokee web server
#
# chkconfig: - 60 10
# description: cherokee web server
# processname: cherokee
# config: /etc/cherokee/httpd.conf

### BEGIN INIT INFO
# Provides: cherokee http-server
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 3 4 5
# Short-Description: cherokee web server
# Description: cherokee web server
### END INIT INFO

WITHOUT_RC_COMPAT=1

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

PIDFILE=/var/run/cherokee.pid
LOCKFILE=/var/lock/subsys/cherokee
RETVAL=0

start() {
	start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" -- cherokee -d
	RETVAL=$?
	return $RETVAL
}

stop() {
	stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" -- cherokee
	RETVAL=$?
	return $RETVAL
}

restart() {
	stop
	start
}

reload() {
	msg_reloading cherokee
	stop_daemon --pidfile "$PIDFILE" -USR1 -- cherokee
	RETVAL=$?
	return $RETVAL
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
	status cherokee
	;;
  restart)
	restart
	;;
  reload)
	reload
	;;
  condstop)
	if [ -e "$LOCKFILE" ]; then
	    stop
	fi
	;;
  condrestart)
	if [ -f "$LOCKFILE" ]; then
	    stop
	    start
	fi
	;;
  *)
	msg_usage "${0##*/} {start|stop|status|restart|condstop|reload|condrestart}"
	exit 1
esac

exit $RETVAL
