LOGDIR=/var/sadm/patch/115861-05
LOG=$LOGDIR/prepatch.log

# check for root
user=`/bin/id | /usr/bin/grep root | /usr/bin/wc -l`
if [ $user -eq 0 ]; then
	msg="You must be root to execute this script."
        echo "$msg"
        exit 1
fi

/bin/mkdir -p $LOGDIR

# stop esm and smicc if not running as part of esmpatch
if [ "$ESM_CONTEXT" != "patch" ]; then

    ESM_BASE=`/usr/bin/pkgparam SUNWstm ESM_BASE`
    if [ $? -ne 0 ]; then
	msg="Could not determine ESM location."
        echo "$msg"
	echo "$msg" >> $LOG
        exit 1
    fi

    $ESM_BASE/bin/esmcontrol -m stop >> $LOG 2>&1

    SMSERVER=/usr/sbin/smcwebserver
    if [ -f "$SMSERVER" ]; then
        $SMSERVER stop >> $LOG 2>&1
    fi
fi
