#!/bin/sh
#
# pbssched: This script will start and stop the PBS Scheduler
#
# description: PBS is a batch versitle batch system for SMPs and clusters
#
### BEGIN INIT INFO
# Provides: pbssched
# Required-Start: $network pbsserv $remote_fs
# Required-Stop: $network
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Start PBS Sceduler
### END INIT INFO             

# Source the library functions
. /etc/rc.status

# First reset status of this service
rc_reset  
case "$1" in
  start) 
	echo -n "Starting the PBS Scheduler"
	startproc /opt/pbs/sbin/pbs_sched 
	rc_status -v
  ;;
  stop)
	echo -n "Stopping the PBS Scheduler"
	killproc -TERM /opt/pbs/sbin/pbs_sched
	rc_status -v
  ;;
  status)
        echo -n "Checking for PBS Scheduler: "
	checkproc /opt/pbs/sbin/pbs_sched  
	rc_status -v 
  ;;
  try-restart)
        ## Stop the service and if this succeeds (i.e. the
        ## service was running before), start it again.
	$0 status >/dev/null &&  $0 restart  
        # Remember status and be quiet
        rc_status
        ;;           
  restart)
	echo "Restarting the PBS Scheduler"
	$0 stop
	$0 start
	rc_status
  ;;
  *)
        echo "Usage: $0 {start|stop|status|restart|try-restart}"
        exit 1
esac

rc_exit 
