#!/bin/bash
#
# thttpd This shell script takes care of starting and stopping \
# thttpd (tiny/turbo/throttling HTTP server)
#
# chkconfig: - 85 15
# description: This tiny/turbo/throttling HTTP server is used to \
# serve HTML files and CGI.
#
# processname: thttpd
# pidfile: /var/run/thttpd.pid
# config: /etc/thttpd.conf
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0
[ -f /etc/thttpd.conf ] || exit 0
RETVAL=0
prog="thttpd"
start() {
# Start daemons.
echo -n $"Starting $prog: "
daemon thttpd -C /etc/thttpd.conf
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/thttpd
echo
return $RETVAL
}
stop() {
# Stop daemons.
echo -n $"Stopping $prog: "
killproc thttpd
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/thttpd
echo
return $RETVAL
}
restart() {
stop
start
}
nicestop() {
# Stop gracefully (once active connections are ended)
echo -n $"Stopping $prog gracefully: "
killproc thttpd -USR1
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/thttpd
echo
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status thttpd
;;
restart)
restart
;;
condrestart)
[ -f /var/lock/subsys/thttpd ] && restart
;;
nicestop)
nicestop
;;
*)
echo $"Usage: thttpd {start|stop|status|restart|condrestart|nicestop}"
exit 1
esac
exit $?