#! /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 GNU/Linux
#		by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
#		Modified for RedHat Linux
#		by Tom Weber <xrpm@abyss.4t2.com>.
#
# Version:	@(#)skeleton  1.8  03-Mar-1998  miquels@cistron.nl
#
# Caudium init.d startup file
#
# $Id: init.d,v 1.13 2002/01/03 17:05:36 grendel Exp $
# chkconfig: 2345 95 15
# description: Caudium is a powerful modular Webserver based on Roxen 1.3
#       Challenger Code.
# pidfile: /var/run/caudium/caudium.pid

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

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

SourceIfNotEmpty /etc/default/caudium

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/caudiumctl

test -x $DAEMON || exit 0

stop() {
    echo -n "Stopping Caudium: "
    if ${DAEMON} stop > /dev/null 2>&1; then
	echo_success
    else
	echo_failure
    fi
    echo
}

start() {
    echo -n "Starting Caudium: "
    if ${DAEMON} start > /dev/null 2>&1; then
	echo_success
    else
	echo_failure
    fi
    echo
}

reload() {
    echo -n "Reloading Caudium Configuration: "
    if ${DAEMON} reload > /dev/null 2>&1; then
	echo_success
    else
	echo_failure
    fi
    echo
}

case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  reload)
	reload
	;;
  restart)
	stop
	sleep 3
	start
	;;
  *)
	N=$0
	# echo "Usage: $N {start|stop|restart|reload}" >&2
	echo "Usage: $N {start|stop|restart|reload}" >&2
	exit 1
	;;
esac

exit 0
