#!/bin/sh
#
# pbs_sched	This script will start and stop the PBS Scheduler
#
# chkconfig: 345 95 5
# description: PBS is a batch versatile batch system for SMPs and clusters
#
### BEGIN INIT INFO
# Provides:       pbs_sched
# Required-Start: $local_fs $network $named $remote_fs $syslog $time
# Should-Start: pbs_server
# Required-Stop:
# Should-Stop:
# Default-Start:  3 5
# Default-Stop:
# Description: Torque is a versatile batch system for SMPs and clusters
### END INIT INFO

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

PBS_DAEMON=/usr/sbin/pbs_sched
export PBS_DAEMON

if [ -f /etc/sysconfig/pbs_sched ];then
   . /etc/sysconfig/pbs_sched
fi

# let see how we were called
case "$1" in
	start) 
		echo -n "Starting TORQUE Scheduler: "
		daemon $PBS_DAEMON
		RET=$?
		touch /var/lock/subsys/pbs_sched
		echo
		;;
	stop)
		echo -n "Shutting down TORQUE Scheduler: "
		killproc pbs_sched
		RET=$?
		rm -f /var/lock/subsys/pbs_sched
		echo
		;;
	status)
		status pbs_sched
		RET=$?
		;;
	restart)
		$0 stop
		$0 start
		;;
	try-restart)
		[ -f /var/lock/subsys/pbs_mom ] && $0 restart
		;;
 	reload|force-reload)
		echo -n "Reloading pbs_sched: "
		killproc pbs_sched -HUP
		RET=$?
		echo
		;;
	*)
		echo "Usage: pbs_sched {start|stop|restart|status}"
		exit 1
esac
exit $RET
