#! /bin/bash . acsstartupLogging.sh . acsstartupConstants . acsstartupAcsInstance #******************************************************************************* # E.S.O. - VLT project # # "@(#) $Id: acsStopORBSRVC,v 1.43 2012/05/31 14:56:22 acaproni Exp $" # # who when what # -------- ---------- ---------------------------------------------- # msekoran 2013-10-17 created # #************************************************************************ # NAME # # SYNOPSIS # # DESCRIPTION # # FILES # # ENVIRONMENT # # RETURN VALUES # # CAUTIONS # # EXAMPLES # # SEE ALSO # # BUGS # #------------------------------------------------------------------------ # #ACS_LOG_COMMAND $@ COMMAND=`basename $0` PARAMS=$* ### ### ----------- Command Line Parsing --------------------- # # These will contain the parsing results (CL_XXX, CL = command line) # CL_BASEPORT= CL_HELP= # # These options can be recognized (longopts comma-separated. colon means argument is required) # LONGOPTS=help,baseport: SHORTOPTS=hb: # # Usage info. Be nice and keep this up-to-date! # function printUsage { echo "Frees ACS_INSTANCE.b directory by renaming it to ACS_INSTANCE.b." echo "" echo "Usage: `basename $0` [OPTIONS] " echo "Options: " echo " -b | -baseport INSTANCE the acs instance (0-9) you want to use" echo " -h | -help prints this help and exits" } # # Run getopt (posixly_correct needed). We run twice: # First run is simply to check the commandline for correctness # Second run is the real deal which replaces the command line args with getopt's output export POSIXLY_CORRECT=1 getopt -n `basename $0` -Q -u -a -l $LONGOPTS $SHORTOPTS "$@" || { printUsage exit $EC_BADARGS; } set -- `getopt -u -a -l $LONGOPTS $SHORTOPTS "$@"` # # Iterate over getopt's output and set CL_XXX variables accordingly # while : do case "$1" in --baseport) CL_BASEPORT=$2 ; shift ;; -b) CL_BASEPORT=$2 ; shift ;; --help) CL_HELP=true ;; -h) CL_HELP=true ;; --) break ;; esac shift done shift # restore export POSIXLY_CORRECT= unset POSIXLY_CORRECT if [ "$CL_HELP" ] ; then printUsage exit $EC_OK fi # # (Note: Rest of command line now in $@ ) # ### ---------- End of Command Line Parsing ------------- #Check command-line args for baseport option if [ "$CL_BASEPORT" ] then ACS_INSTANCE="$CL_BASEPORT" fi INSTANCE_DIR=`getInstanceDirName $ACS_INSTANCE` ACS_LOG_COMMAND $@ ######################################################################## #SANITY CHECKS------------------------------------------------------- if [ ! -d $INSTANCE_DIR ] then ACS_LOG_DEBUG "$COMMAND" "Lock directory '$INSTANCE_DIR' does not exist!" elif [ ! -w $INSTANCE_DIR ] then ACS_LOG_ERROR "$COMMAND" "Lock directory '$INSTANCE_DIR' is not owned by '$USER'!" exit $EC_CANNOTUSE fi ACS_LOG_INFO "$COMMAND" "Freeing $INSTANCE_DIR" if [ -d $INSTANCE_DIR ]; then mv $INSTANCE_DIR $INSTANCE_DIR.`date +%s` &> /dev/null || (ACS_LOG_ERROR "$COMMAND" "Cannot move $INSTANCE_DIR") fi # # ___oOo___