#!/bin/sh

# hpux preinstall script

#check for already installed agent
if [ ! -f /opt/BESClient/bin/BESClient ]; then
	exit 0
fi

# if BESAgent is running, try to stop it
count=0
while [ $count -le 10 ]
do
    if ! ps -e | grep -q BESClient ; then
		break
	fi

	/sbin/init.d/BESClient stop
	count=`expr $count + 1`
	sleep 3
done

if ps -e | grep -q BESClient ; then
	echo cannot strop BESClient
	exit -1
fi

# remove any potentially conflicting files from the previous install

rm -f /opt/BESClient/BESLib/lib*.sl
rm -f /opt/BESClient/BESLib/Inspectors/lib*.sl

exit 0

