#!/bin/bash
# Startup script for the thttpd wed server
#
# chkconfig: 345 85 15
# description: thttpd is a very fast web server.
# 
# processname: thttpd
# source function library.
. /etc/rc.d/init.d/functions

RETVAL=0

start () {
	echo -n $"Starting thttpd: "
	daemon /usr/sbin/thttpd -r -d /var/thttpd -u thttpd -c 'cgi-bin/*'
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && touch /var/lock/subsys/thttpd
	return $RETVAL
}

stop () {
	echo -n $"Shutting down thttpd: "
	killproc thttpd
	RETVAL=$?
	[ $RETVAL = 0 ] && rm -f /var/lock/subsys/thttpd
}

restart() {
	stop
	start
}
	
case "$1" in
  start)
	start
	;;
  
  stop)
	stop
	;;
  
  restart)
	restart
  ;;

  condrestart)
	[ -f /var/lock/subsys/thttpd ] && restart || :
	;;

  status)
	status thttpd
	;;
  *)

	echo $"Usage: thttpd {start|stop|restart|status|condrestart}"
	exit 1
esac

exit $RETVAL

