#!/bin/sh
#
#ident  "@(#)preremove 1.26     03/03/21 SMI"
#
# Copyright (c) 2001 by Sun Microsystems, Inc.
#
#	preremove script for package: SUNWwbcor
#

# Exit codes for installation scripts 
e_ok=0      
e_fatal=1      # stop installation on this exit
e_warning=2    # Installation will go on. 
e_int=3        # Interrupted. Stop installation
e_reboot=10    # User must reboot after installation of all selected packages
e_rebootnow=20 # User must reboot right after installation of current package
               # To be added to one of the single-digit exit code above
# Trap interrupt
trap `exit $e_int` 15

#
#	Stop running process(es)
#
LOGDIR=${BASEDIR}/var/sadm/wbem
if [ ${BASEDIR} = "/" ]
then
	for daemon in cimbootserver cimomserver space rmid; do
		pidfile=/var/sadm/wbem/log/$daemon.pid
		if [ -f $pidfile ]; then
			pid=`/usr/bin/cat $pidfile`
			[ "$pid" -gt 0 ] && kill $pid >/dev/null 2>&1
			rm -f $pidfile
		fi
	done

	#In case CIM Object Manager is not stopped
	wpid=`pgrep -f Dpropdir`
	if [ -n "$wpid" ]	
	then
		kill -9 $wpid
	fi
	# Remove the present; Move the old log back; for S8 only
	if [ ! -d ${LOGDIR}/logru3/regDir ]; then
	    /usr/bin/rm -rf ${LOGDIR}/logr
	    /usr/bin/mv ${LOGDIR}/logru3 ${LOGDIR}/logr 2> /dev/null
	fi
fi

SUBAGENTDIR=${BASEDIR}/etc/snmp/conf
/usr/bin/rm -rf ${LOGDIR}/log
/usr/bin/rm -rf ${LOGDIR}/snmp
/usr/bin/rm -rf ${SUBAGENTDIR}/snmpXwbem.*

exit $e_ok 
