#! /bin/sh

#
# chkconfig: 3 90 99
# description: Condor batch system
#
# condor script for SysV-style init boot scripts.  
#
# Usually this would be installed as /etc/init.d/condor with soft
# links put in from /etc/rc*.d to point back to /etc/init.d/condor to
# determine when Condor should be started and stopped.  Exact
# directories or details of the links you should use will vary from
# platform to platform. 
#
# To customize, all you need to do is edit the MASTER line below.
# condor_install (if run as root) will do that for you.  The PS line
# should be the full path and arguments to a ps command that dumps out
# all running processes.  This should be correct on all platforms.
#
# Author: Derek Wright <wright@cs.wisc.edu> 2/27/98
#

MASTER=/opt/condor/sbin/condor_master
PS="/bin/ps auwx"

case $1 in
'start')
    if [ -x $MASTER ]; then
        echo "Starting up Condor"
        $MASTER
    else
        echo "$MASTER is not executable.  Skipping Condor startup."
        exit 1
    fi
    ;;

'stop')
    pid=`$PS | grep condor_master | grep -v grep | awk '{print $2}'`
    if [ -n "$pid" ]; then 
        # send SIGQUIT to the condor_master, which initiates its fast
        # shutdown method.  The master itself will start sending
        # SIGKILL to all it's children if they're not gone in 20
        # seconds. 
        echo "Shutting down Condor (fast-shutdown mode)"
        kill -QUIT $pid
    else
        echo "Condor not running"
    fi	
    ;;

*)
    echo "Usage: condor {start|stop}"
    ;;

esac;