#!/bin/sh 
# This script does pre remove tasks for
# the Seabreeze packages.
#
# Copyright (c) 1998 by Sun Microsystems, Inc.
# All rights reserved.
#
# @(#)preremove	1.5     04/16/99
#

############################################################################
# Set version subdirectory and configuration paths

VERSIONDIR="3_0"
SEAETCROOT="/etc/opt/SUNWseam" 
SEAVAROOT="/var/opt/SUNWseam" 
SEAROOT="${BASEDIR}/SUNWseam"

SEABASEDIR="${SEAROOT}/${VERSIONDIR}"
SEAETCDIR="${SEAETCROOT}/${VERSIONDIR}"
SEAVARDIR="${SEAVAROOT}/${VERSIONDIR}"


############################################################################
# Stop any client processes that are running

echo "Stopping any management client applications, if they are running..."
PIDS=`/usr/bin/ps -deaf | grep "admin.client" | grep -v grep | cut -c1-24 | awk '{print $2}'`
PIDS="${PIDS} `/usr/bin/ps -deaf | grep "batchapp" | grep -v grep | cut -c1-24 | awk '{print $2}'`"
if [ "${PIDS}" = "" ]; then
	echo "No management client applications are running..."
fi
for PID in ${PIDS}
do
	echo "Stopping management client application process ${PID}"
	kill ${PID}
done

############################################################################
# Stop the daemon process if it is running

echo "Stopping the management server, if it is running..."
/etc/init.d/admsvr${VERSIONDIR} stop


############################################################################
# Remove our entry from smc if smc exists

if [ -x /usr/sadm/smc/lib/smcappadm ]; then
	echo "Unregistering with the SMC management console..."
	/usr/sadm/smc/lib/smcappadm -U -n "AdminSuite"   -b "$SEABASEDIR/bin/admapp" -t XAPP -c "Infrastructure" -p root -i /usr/sadm/smc/images/xapp.gif
fi

exit 0
