#!/bin/bash
PATH=/usr/bin:/bin:$PATH
EG_BIN=/opt/egurkha/bin
export EG_BIN PATH
Check=`/opt/egurkha/bin/xvt stop_solaced`
export Check
if [ $Check = "FALSE" ]
then
echo "The eG solace must be setup by the eG user. Exiting ..."
exit
fi
#============================================================================
# stop_solaced: shell script that stops Solace receiver 
#============================================================================

pid_list=`ps -e -o pid,args | grep -i "SolaceTopicSubscriber" | grep -v "grep" | grep -v "stop_solaced"| awk '{print $1}'`

#get the list of pids 
if [ "$pid_list" ] 	# if Solace receiver is running
then
	for pid in $pid_list    # for each pid
	do
		# kill each child
		kill -9 $pid #> /dev/null 2>&1 
		#z=1
	done
fi
#if z 
#if [$1]
echo "------------------------------------------------"
echo "Solace receiver has been stopped successfully."
echo "------------------------------------------------"
#fi 
