#!/bin/sh
#
# Init file for the Job Archiving Daemon
#
# chkconfig: 2345 20 80
# description: jobarchived archives information on nodes in RRDS and batch jobs in SQL
#
# processname: jobarchived
# config: /etc/jobarchived.conf
# config: /etc/sysconfig/jobarchived
# pidfile: /var/run/jobarchived

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

RETVAL=0
NAME=jobarchived
DAEMON=/usr/sbin/jobarchived
DESC="Job Archiving Daemon"

PIDFILE=/var/run/$NAME.pid

OPTIONS=""

if [ -r /etc/sysconfig/$NAME ]
	then
		source /etc/sysconfig/$NAME
fi

start() {
	echo -n $"Starting $DESC: "
	daemon $DAEMON --pidfile="$PIDFILE" $OPTIONS
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$NAME
	return $RETVAL
}

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

restart() {
	stop
	start
}

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

exit $RETVAL
