#!/bin/bash bin=`dirname "$0"` bin=`cd "$bin"; pwd` source $bin/ps-functions SCRNAME="" # Process the parameters declare -i numOfArgs=$# let numOfArgs++ while [ $numOfArgs -ne $OPTIND ]; do getopts "ho" optKey if [ "$optKey" == "?" ]; then optKey="h" fi case $optKey in h) echo -en "\nUsage of ${0##*/}:\n\n" echo -en "Switch off the Secondo Monitors running on the current node.\n\n" echo -en " -h Print this message and exit. \n\n" echo -en " -o Switch off a Secondo Monitor based on Own configuration \n" echo -en " $HOME/.parasecrc \n\n" exit 0;; o) if [ ! -f "$HOME/.parasecrc" ]; then echo -e "The local parallel secondo configuration $HOME/.parasecrc doesn't exist." exit -1; else source $HOME/.parasecrc fi ;; esac done declare -i SRCNUM=0 # Get the screen session name by reading the temporal file that is created during the start up period #IFS=':' declare -a MSECARR=($(echo $PARALLEL_SECONDO | tr ':' ' ')) #for MINISEC in $PARALLEL_SECONDO; do for MINISEC in ${MSECARR[*]}; do # CONFFILE="${MINISEC}/${PARALLEL_SECONDO_MINI_DIR}/bin/SecondoConfig.ini" MINISEC="${MINISEC}/${PARALLEL_SECONDO_DATASERVER_NAME}/${PARALLEL_SECONDO_MINI_NAME}" CONFFILE="${MINISEC}/bin/SecondoConfig.ini" if [ ! -f $CONFFILE ]; then echo "The configure file $CONFFILE doesn't exist, cannot stop the corresponding Monitor." >&2 continue fi LFNAME="/tmp/SECMON_$(get_secPort $CONFFILE)" REGNAME="/tmp/$(get_regFileName $CONFFILE)" if [ -f $LFNAME ]; then SCREVAR=$(cat "$LFNAME") sid_TTY=${SCREVAR#*@} else echo "No SecondoMonitor is running based on $CONFFILE" >&2 continue fi if [ "$sid_TTY" != "" ]; then exec_scr_commands ${sid_TTY} "quit" "y" "exit" # Don't use "yes", which is a linux command smCnt=`screen -ls 2>/dev/null | grep "$sid_TTY" | grep Detached | wc -l` if [ $smCnt -gt 0 ];then # Cannot kill the screen normally kill "$sid_TTY" fi # Delete the mark file and the register file of Secondo Monitor let SRCNUM++ rm $LFNAME rm $REGNAME echo "A Secondo Monitor of ${MINISEC} with screen ID ${sid_TTY} is switched off." fi done # Kill the started CollectFlobServer daemons pkill -u ${USER} collectFl if [ $SRCNUM -le 0 ]; then echo -e "No Monitors can be switched off by the current user.\n" >&2 exit -1; fi exit 0