#!/bin/sh
# DESCRIPTION: Example file to put in /etc/init.d to run daemon
#
# Copyright 2002-2004 by Wilson Snyder.  This program is free software;
# you can redistribute it and/or modify it under the terms of either the GNU
# General Public License or the Perl Artistic License.
#
# chkconfig: 23456 99 10
# description: Slreportd provides process reporting services for Schedule::Load
# processname: slreportd

state=$1

case $state in
'start')
        echo starting /usr/local/bin/slreportd if present
	rm -f /tmp/TTYDEVS
	mkdir -p /usr/local/lib/rschedule
	chmod a+rwx /usr/local/lib/rschedule
        [ -f /usr/local/bin/slreportd ] &&  su daemon -c /usr/local/bin/slreportd &
	exit 0
        ;;
  stop)
        if test "x`pidof -o $$ -o $PPID -x slreportd`" != x; then
                echo -n $"Stopping slreportd: "
                kill `pidof -o $$ -o $PPID -x slreportd`
                echo
        fi
	exit 0
        ;;
  restart|reload)
	$0 stop
	$0 start
	exit 0
	;;
  status)
        if test "x`pidof -o $$ -o $PPID -x slreportd`" != x; then
  	        ps f -ww `pidof -o $$ -o $PPID -x slreportd`
        fi
	exit 0
	;;
*)
	echo $"Usage: $0 {start|stop|restart|reload|status}"
	exit 1
esac
