#!/bin/sh
#
# pbs_server	This script will start and stop the TORQUE Server
#
# chkconfig: 345 85 85
# description: TORQUE is a batch versatile batch system for SMPs and clusters
#
# Source the library functions
. /etc/rc.d/init.d/functions

PBS_PREFIX=/opt/pbs
PBS_HOME=/var/spool/pbs
OSCAR_CONFIG_OPTIONS="-L $PBS_HOME/server_logs/pbs_server.log"
CONFIG_OPTIONS="$OSCAR_CONFIG_OPTIONS"

# let see how we were called
case "$1" in
	start) 
		gprintf "Starting TORQUE Server: "
		if [ ! -r $PBS_HOME/server_priv/serverdb ]; then
			 CONFIG_OPTIONS="$CONFIG_OPTIONS -t create"
		fi
		daemon $PBS_PREFIX/sbin/pbs_server $CONFIG_OPTIONS
		echo
		;;
	stop)
		gprintf "Shutting down TORQUE Server: "
		killproc pbs_server
		echo
		;;
	status)
		status pbs_server
		;;
	restart)
		$0 stop
		$0 start
		;;
	*)
		gprintf "Usage: pbs_server {start|stop|restart|status}\n"
		exit 1
esac
