John Kewley's modified Condor init script (SysV style)

#!/bin/sh

# condor script for SysV-style init boot scripts.
#
# Following lines work on RedHat and derivative Linuxes
# chkconfig: 345 90 99
# description: Condor batch system
#
# Following lines work on SUSE
### BEGIN INIT INFO
# Provides: condor
# Required-Start: $network $remote_fs $ypbind
# Required-Stop: $network
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Condor batch system
### END INIT INFO
#
# 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.
#
# Many installations (incl RedHat) can use /usr/sbin/chkconfig to setup these
# links for you.
#
# SUSE uses ??
#
# 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
# Amended: John Kewley <j.kewley@dl.ac.uk> 5/5/2004

PS="/bin/ps auwx"
CONDOR_SH=/etc/profile.d/condor.sh

setup()
{
    # Need to setup both CONDOR_CONFIG and CONDOR_ROOT
    if [ -n "$CONDOR_CONFIG" ]; then
        CONDOR_ROOT=`dirname $CONDOR_CONFIG`/..
    else
        if [ -r ${CONDOR_SH} ]; then
            . ${CONDOR_SH}
        else
            echo "CONDOR_CONFIG is not set-up.  Aborting"
            exit 1
        fi
    fi

        # set up globus stuff as well
        #. /etc/profile.d/globus.sh

    MASTER=${CONDOR_ROOT}/sbin/condor_master
    STATUS=${CONDOR_ROOT}/bin/condor_status
}

start()
{
    setup

    if [ -x ${MASTER} ]; then
        echo "Starting up Condor"
        ${MASTER}
    else
        echo "${MASTER} is not executable.  Skipping Condor startup."
        exit 1
    fi
}

stop()
{
    # setup not needed
    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
}

status()
{
    setup
    if [ -x ${STATUS} ]; then
        ${STATUS}
    else
        echo "${STATUS} is not executable."
        exit 1
    fi
}

case $1 in
'start')
    start
    ;;

'restart')
    stop
    /bin/sleep 2
    start
    ;;

'stop')
    stop
    ;;

'status')
    status
    ;;
*)
    echo "Usage: condor {start|restart|stop}"
    exit 1
    ;;

esac

exit 0
Topic revision: r1 - 03 Mar 2009 - 09:56:39 - RobAllan
 
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback