#!/bin/bash
#
# sccl_stop_stst stoppt ein Test-Paket im Script-Cluster
#
# Aufruf:
#
# sccl_stop_stst <lock>
#
# Das Test-Paket <lock> wird gestoppt.
#
########################################################################################
#echo $0 $*
#
. `dirname $0`/globals.functions
#
########################################################################################
#
if [[ $# -ne 1 ]]
 then
  echo "usage: $0 <lock>"
  exit 1
fi
#
if [[ -s  $LOCKDIR/$1.pid ]]
 then
  PID=`cat $LOCKDIR/$1.pid`
  if [[ -n "$PID" ]]
   then
    if ps -efa | awk '$2 == '$PID'{print $0}' | grep -q " /usr/share/sccl/bin/sccl_probe_res $1 "
     then
      kill $PID
      echo "Test-Paket $1 gestoppt."
      rm $LOCKDIR/$1.pid
    else
      echo "Test-Paket $1 konnte nicht bestimmt werden."
      exit 2
    fi
  else
    echo "No PID in $LOCKDIR/$1.pid"
    exit 3
  fi
else
  echo "No $LOCKDIR/$1.pid"
  exit 4
fi
