File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / thttpd / contrib / redhat-rpm / thttpd.init
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 17:21:13 2012 UTC (12 years, 5 months ago) by misho
Branches: thttpd, MAIN
CVS tags: v2_25b, HEAD
thttpd

#!/bin/bash
# The following two lines enable chkconfig(1) to manipulate this script
# chkconfig: 2345 99 01
# description: control Jef Poskanzer's tiny/turbo/throttling http daemon

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

pidfile=/var/run/thttpd.pid
pid=`cat $pidfile 2>/dev/null`

if test -n "$pid" && kill -0 $pid 2>/dev/null; then
	dead=no
else
	dead=yes
fi

die(){
	echo -n "$*"; echo_failure; echo ''
	exit 1;
}

case "$1" in
 start)	test "$dead" = yes || die thttpd is already running
	echo -n "Starting thttpd: "
	daemon /usr/sbin/thttpd -C /etc/thttpd.conf
	touch /var/lock/subsys/thttpd
	echo_success;echo ''
	exit 0
	;;
  stop)	echo -n "Gently shutting down thttpd: "
	signal=USR1
	;;
  kill)	echo -n "Violently killing thttpd: "
	signal=INT
	;;
status)	status thttpd; exit $?;;
restart) $0 stop; sleep 2; exec $0 start;;
     *)	die "Usage: thttpd {start|stop|restart|status}";;
esac

test "$dead" = no || die thttpd is not running
kill -$signal $pid
sleep 2
kill -0 $pid 2>/dev/null && die "thttpd[$pid] will not die"
rm -f /var/lock/subsys/thttpd
echo_success; echo ''

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>