#!/bin/sh
#
# /etc/rc.d/init.d/and, /sbin/init.d/and, /etc/init.d/and
#
# SysV init.d compliant startup script for auto nice daemon.
#
# 1999, 2000, 2001 Patrick Schemitz <schemitz@users.sourceforge.net>
# http://and.sourceforge.net/
# 
# chkconfig: - 90 10
# description: automatically renice and kill jobs.
#
# processname: and
# config: /etc/and.conf
#

### BEGIN INIT INFO
# Provides: and
# Required-Start: $syslog
# Required-Stop:
# Default-Stop: 0 6
# Short-Description: Automatically renice and kill jobs
# Description: Autmatically renice and kill jobs
### END INIT INFO

prog=and
and_bin=/usr/sbin/and
and_conf=/etc/and/and.conf

. /etc/rc.d/init.d/functions

AND_FLAGS=""
test -r /etc/sysconfig/and && . /etc/sysconfig/and

start() {
    echo -n $"Starting auto nice daemon:"
    daemon /usr/sbin/and $AND_FLAGS >/dev/null 2>&1
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
}

stop() {
    echo -n $"Shutting down auto nice daemon:"
    killproc and -QUIT
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -rf /var/lock/subsys/$prog
}

restart() {
    stop
    start
}

RETVAL=0

[ -x $and_bin -a -s $and_conf ] || exit 0

case "$1" in
    start)
	start
	;;
    stop)
	stop
	;;
    restart|reload)
	stop
	start
	RETVAL=$?
	;;
    condrestart)
	[ -e /var/lock/subsys/$prog ] && restart || :
	;;
    status)
	status $prog
	;;
    *)
	echo "Usage: $0 {start|stop|restart|condrestart|status}"
	exit 1
esac

exit $RETVAL