#!/bin/bash
#
#	/etc/rc.d/init.d/salinfo_decode
#
# Starts the salinfo_decode daemon
#
# chkconfig: 345 95 5
# description: Starts a salinfo_decode task for each SAL record type \
#    then monitors the status of the chldren.
# processname: salinfo_decode

# Source function library.
. /etc/init.d/functions

prog="salinfo_decode_all"

test -x /usr/sbin/$prog || exit 0

. /etc/sysconfig/salinfo_decode

# salinfo_decode itself needs environment variables set.  We need to be sure
# they are exported if set.

# Required:
export DIRECTORY=${DIRECTORY:?}
export RETRIES=${RETRIES:?}

# Optioanl
[ -n "$INODE_PCT" ] && export INODE_PCT
[ -n "$SPACE_PCT" ] && export SPACE_PCT
[ -n "$RATE_LIMIT" ] && export RATE_LIMIT
[ -n "$INIT_RATE_LIMIT" ] && export INIT_RATE_LIMIT
[ -n "$TRIGGER" ] && export TRIGGER
[ -n "$MCA_RATE_LIMIT" ] && export MCA_RATE_LIMIT

#
#	See how we were called.
#

start() {
	# Check if salinfo_decode is already running
	if [ ! -f /var/lock/subsys/$prog ]; then
	    echo -n $"Starting $prog: "
	    daemon $prog
	    RETVAL=$?
	    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
	    echo
	fi
	return $RETVAL
}

stop() {
	echo -n $"Stopping $prog: "
	killproc $prog
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
	echo
        return $RETVAL
}


restart() {
	stop
	start
}

reload() {
	restart
}

case "$1" in
start)
	start
	;;
stop)
	stop
	;;
reload|restart)
	restart
	;;
condrestart)
	if [ -f /var/lock/subsys/$prog ]; then
	    restart
	fi
	;;
status)
 	status $prog
	;;
*)
	echo $"Usage: $0 {start|stop|restart|condrestart|status}"
	exit 1
esac

exit $?
