#!/bin/sh # # --------- # AiresStop # --------- # # This is a sh script to shutdown AIRES processes currently running. # The shutdown will be done in an ordered fashion, saving all the # work already done. If you want an emergency stop, use script # AiresKill instead. # # Written by S. J. Sciutto, La Plata 1996, 1997, 2001. # # Last modification: 05/Nov/2001. # # # Usage: # # AiresStop [-q | -f] [spoolnumber] # # ############################################################################### # # Setting predefinded constants. # AiresSet="${HOME}/.airesrc" if [ -f $AiresSet ] then . $AiresSet else # # .airesrc file does not exist, trying in default bin directory. # AiresSet="${HOME}/aires/current/bin/airesrc" if [ -f $AiresSet ] then . $AiresSet else # # Have no other ideas about the setting file. # echo echo Cannot find internal script file! echo exit fi fi # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Analysing the input parameters. # case _$1 in # _) # No arguments. Verbose and querying mode. verb=verbose inqu=inquire ;; _-q) verb= inqu= shift ;; _-f) verb=verbose inqu= shift ;; _-*) echo "Usage: AiresStop [-q | -f] [spoolnumber]" exit ;; _*) # Only spool arguments. Verbose and querying mode. verb=verbose inqu=inquire ;; esac # # Completing the definition of constants. # if [ $1 ] then spoolnumber=$1 fi . ${Airesbindir}/AiresSetParams # currdir="`pwd`" # # Checking the current status of the runner system. # cd $spooldir # spoolfiles=$spoolfiledef if [ "_$spoolfiles" != "_`echo $spoolfiledef`" ] then # # There are tasks in spool. Checking if AiresRunner is up. # if [ -f $rpf ] then # # There is a PID file. Checking if the process exists. # pidinfo="`cat $rpf`" set xxx $pidinfo pid=$2 # oatp= if [ "_$AiresTestProcess" != "_" ] then atp=$AiresTestProcess if [ -x $atp ] then oatp=TRUE fi fi # if [ $oatp ] then running="`$atp $pidinfo`" else $pscomm > __AIRES_STOP.TMP nproc="`grep -c $pid __AIRES_STOP.TMP`" rm -f __AIRES_STOP.TMP if [ $nproc = 0 ] then running=NO else running=YES fi fi # if [ $running = YES ] then noprocess= elif [ $running = NO ] then noprocess=TRUE if [ $verb ] then echo "Detected aborted AiresRunner process (PID number $pid)." fi else noprocess= echo PID file exists but status of process is unknown. fi # else # # No PID file. # noprocess=TRUE # fi # if [ $noprocess ] then # # There are no processes. # if [ $verb ] then echo "No processes to stop." fi # else # # There is a process running right now. # if [ $inqu ] then # echo $echonlf "Detected a running process (PID number $pid)" if [ -f $rlf ] then echo "" echo "(Process started at date: `cat $rlf`)." else echo "." fi echo $echonlf "Do you wish to shutdown the process now? [Y]: " read sw echo if [ "_$sw" = "_" -o "_$sw" = "_y" -o "_$sw" = "_Y" -o \ "_$sw" = "_yes" -o "_$sw" = "_YES" -o "_$sw" = "_Yes" ] then goon=TRUE echo "Urgent shutdown or shutdown after completing current run?" $echonlf "(U=Urgent, N=Not urgent) [U]: " read uw echo if [ "_$uw" = "_" -o "_$uw" = "_u" -o "_$uw" = "_U" -o \ "_$uw" = "_urgent" -o "_$uw" = "_Urgent" ] then urgent=TRUE else urgent= fi else goon= fi # else goon=TRUE urgent=TRUE fi # # Creating the file AIRES.STOP # if [ $goon ] then # # Getting the current working directory. # directory="`$lscomm`" set $directory WorkingDirectory=$currdir . ${spooldir}/$1 # rm -f ${WorkingDirectory}/AIRES.STOP if [ $urgent ] then echo "Urgent" > ${WorkingDirectory}/AIRES.STOP else echo "-13333" > ${WorkingDirectory}/AIRES.STOP fi # if [ $verb ] then echo "File ${WorkingDirectory}/AIRES.STOP was created." echo fi # elif [ $verb ] then echo No stop file created. fi # fi # else # # There are no tasks in spool. # if [ $verb ] then echo No tasks in spool ${spoolnumber}. fi # fi # rm -f __AIRES_STOP.* cd $currdir exit # # This script file is part of the AIRES Runner System; # AIRES 2.8.4a distribution. # # xxx 0 Tue Dec 12 16:28:05 ART 2006