#!/bin/bash
#
#	/etc/rc.d/init.d/salinfod
#
# Starts the at daemon
#
# chkconfig: 345 95 05
# description: Extracts SAL erorr reports from the /proc/sal/ files and then 
#     logs the information for the sysadmin to take action on
# processname: salinfod

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

test -x /usr/sbin/salinfod || exit 0

RETVAL=0

#
#	See how we were called.
#

prog="salinfod"
subsys="/var/lock/subsys/salinfod"

start() {
	# Check if salinfo_decode is already running	
	pid=`pidof -o $$ -o $PPID -o %PPID -x $1 || \
	    pidof -o $$ -o $PPID -o %PPID -x ${base}`
	[ -z "$pid" ] && rm -f $subsys
	if [ ! -f "$subsys" ]; then
	    echo -n $"Starting $prog: "
	    daemon /usr/sbin/salinfod -n
	    RETVAL=$?
	    [ $RETVAL -eq 0 ] && touch $subsys
	    echo
	fi
	return $RETVAL
}

stop() {
	echo -n $"Stopping $prog: "
	killproc /usr/sbin/salinfod
	RETVAL=$?
	pid=`pidof -o $$ -o $PPID -o %PPID -x $1 || \
	     pidof -o $$ -o $PPID -o %PPID -x ${base}`
	[ $RETVAL -eq 0 -o -z "$pid" ] && rm -f $subsys
	echo
        return $RETVAL
}


restart() {
	stop
	start
}	

reload() {
	restart
}	

status_at() {
 	status /usr/sbin/salinfod
}

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

exit $?
exit $RETVAL
