#!/bin/sh
#
# radvd:       Starts the hiawatha web server
#
# Version:      @(#) /etc/rc.d/init.d/hiawatha 1.0
#
# Author:       Joerg Mertin <smurphy@stargate.bln.sub.org> & couriousous <couriousous@zarb.org>
#
# chkconfig: 345 60 10
# description: Hiawatha web server
# processname: hiawatha
# config: /etc/hiawatha/httpd.conf

### BEGIN INIT INFO
# Provides: hiawatha http-server
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 3 4 5
# Short-Description: Hiawatha web server
# Description: Hiawatha web server
### END INIT INFO
# Stolen from radvd script

# Source function library.
if [ -f /etc/init.d/functions ] ; then
	. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
	. /etc/rc.d/init.d/functions
else
	exit 0
fi

RETVAL=0

start() {

	gprintf "Starting Hiawatha web server: "
      	daemon hiawatha
        RETVAL=$?
        echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/hiawatha
	return $RETVAL
}

stop() {
        gprintf "Stopping Hiawatha web server: "
        killproc hiawatha
        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/hiawatha
        echo
	return $RETVAL
}

restart() {
	stop
	start
}       

reload() {
    gprintf "Reloading configuration: "
    killproc hiawatha -USR1
    RETVAL=$?
    echo
    return $RETVAL
}       

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
	status hiawatha
	;;
  restart)
	restart
	;;
  reload)
	reload
	;;
  condrestart)
	if [ -f /var/lock/subsys/hiawatha ]; then
	    stop
	    start
	fi
	;;
  *)
	gprintf "Usage: %s {start|stop|status|restart|reload|condrestart}\n" "$0"
	exit 1
esac

exit $RETVAL

