#!/bin/ksh

# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#ident  "@(#)prepatch 1.3     05/04/03 SMI"


#
#  This program performs the prepatch activity for the patch.
#

BIN_DIR=/usr/sbin
SMREG=${BIN_DIR}/smreg
SMCWEBSERVER=$BIN_DIR/smcwebserver

APPNAME=se6920ui
INSTALLDIR=/usr/share/webconsole
WEBAPPDIR=$INSTALLDIR/$APPNAME
WATCHDOG_NAME=se6000watchdog
INITWBEM=/opt/se6x20/bin/init.wbem_only
BUI_WORKDIR=/var/opt/webconsole/work/com_sun_web_console/localhost/se6920ui
MOFREG=/opt/wsi/bin/mofreg

#
# Stop watchdog from restarting Lockhart or CIMOM
# It is restarted in postpatch via restart_se6000
#

if  pgrep -u 0 -f "$WATCHDOG_NAME" > /dev/null 2>&1
then
  echo "Stopping watchdog..."
  pkill $WATCHDOG_NAME
fi


if [ -x ${SMREG} ]; then
    # Formally unregister the app with Lockhart
    #
    ${SMREG} remove -a $APPNAME
fi

#
# Remove tomcat work directory to avoid cache issue.
# Restarting Lockhart here will likely impact the StorADE typically
# installing the patch.
#
if [ -d ${BUI_WORKDIR} ]; then
    rm -rf ${BUI_WORKDIR}
else
    echo "Couldn't find ${BUI_WORKDIR} so it won't be removed."
fi

#
# Leave Lockhart to not affect StorADE; attemps to use CBEM will get tomcat error
#

#
# Stop CIMOM since SUNWseput will likely deposit new repository under it
#
if [ -x $INITWBEM ]
then
    $INITWBEM stop
fi


exit 0
