# Copyright (c) 1996-2002 Sun Microsystems, Inc.  All Rights Reserved. Sun
# considers its source code as an unpublished, proprietary trade secret, and
# it is available only under strict license provisions.  This copyright
# notice is placed here only to protect Sun in the event the source is
# deemed a published work.  Dissassembly, decompilation, or other means of
# reducing the object code to human readable form is prohibited by the
# license agreement under which this code is provided to the user or company
# in possession of this copy.
#
# RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the Government
# is subject to restrictions as set forth in subparagraph (c)(1)(ii) of the
# Rights in Technical Data and Computer Software clause at DFARS 52.227-7013
# and in similar clauses in the FAR and NASA FAR Supplement.
#

# identify this package for uninstallation
REGTAG=SUNWwbpro
MOF=Solaris_Application.mof
TMPMOF=/tmp/$MOF
WBEM_BASEDIR=/    	     # set default 
USRSADM=$WBEM_BASEDIR/usr/sadm
MOFDIR=$USRSADM/mof


SMCREG=${ROOTDIR}/usr/sadm/bin/smcregister
ADMIN_LIBDIR=${ROOTDIR}/usr/sadm/lib

if [ -f ${TMPMOF} ]; then
  rm $TMPMOF
fi

# clear out the old unreg info since it's not accurate
UNREGDIR=${ROOTDIR}/var/sadm/wbem/logr/unregDir/$REGTAG
rm -rf $UNREGDIR

cat << EOF > $TMPMOF
#pragma namespace("__modify")
#pragma include("$MOFDIR/$MOF")
EOF

#
# This won't work in the diskless client scenario...
#
# /usr/sadm/bin/mofreg -r $REGTAG $TMPMOF
#
# ...but we can do mofreg's work manually to avoid the problem.
#
REGDIR=${ROOTDIR}/var/sadm/wbem/logr/preReg/$REGTAG
mkdir -p $REGDIR

if [ -f ${TMPMOF} ]; then
  cp $TMPMOF $REGDIR
  rm $TMPMOF
fi

if [ ! -d "${ROOTDIR}/var/sadm/smc" ] ; then
    exit 0
fi

# Register tools and services
if [ -f ${SMCREG} ]; then
    ${SMCREG} tool -n com.sun.admin.patchmgr.client.VPatchMgr.jar \
        ${ADMIN_LIBDIR}/patchmgr/VPatchMgr.jar \
	${ADMIN_LIBDIR}/patchmgr/VPatchMgr_classlist.txt \
	${ADMIN_LIBDIR}/patchmgr/VPatchMgrInfo.xml

    ${SMCREG} tool -n com.sun.admin.patchmgr.cli.PatchMgrCli.jar \
        ${ADMIN_LIBDIR}/patchmgr/PatchMgrCli.jar \
        ${ADMIN_LIBDIR}/patchmgr/PatchMgrCli_classlist.txt \
        ${ADMIN_LIBDIR}/patchmgr/PatchMgrCliInfo.xml
fi
exit 0
