#!/bin/sh
#
trap 'echo "$0: Interrupted "; exit 1' INT QUIT
#

PKG=SUNWwbcor
BASEDIR=`/bin/pkgparam $PKG BASEDIR 2>/dev/null`
if [ -z "$BASEDIR" ]    # pkg not installed or installed several times
then
        BASEDIR=/    # set default. Maybe the dir is nfs mounted
fi

#
RMIDPID=${BASEDIR}var/sadm/wbem/log/rmid.pid
stopRmid() {
	if [ -f ${RMIDPID} ]; then
		pid=`/usr/bin/cat ${RMIDPID}`
        	count=`/bin/ps -e| /bin/awk '{print $1}' | grep -c ${pid}`
        	if [ ${count} -eq "1" ]; then
                	kill -TERM ${pid}
        	fi
        	/bin/rm -f ${RMIDPID}
	fi
	#In case rmid is not stopped
	wpid=`pgrep -f rmid`
	if [ -n "$wpid" ]	
	then
		kill -TERM $wpid
	fi
}
# --------- end stopRmid

stopRmid
exit 0
