#!/bin/sh 

# A boilerplate postpatch script for SMC-based tools.  This exact same script
# would also be used for a postbackout script, as once the previous files
# are restored, all that is required is to re-register them and restart
# the server.
#
# Note:  This script can only be used to patch SMC2.1-based tools in Solaris 9
# or greater.  It can NOT be used with SMC 2.0 on Solaris 8.

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

# If SMC repository doesn't exist, server was never started,
# so no need to create registration requests.  Instead, the
# tool's registration script will make the registration requests.
if [ ! -d ${ROOTDIR}/var/sadm/smc ]; then
    exit 0
fi


# Register tools and services
if [ -f ${SMCREG} -a "${ROOTDIR}" = "/" ]; then

    # Add here the same commands you would see in the tool's
    # registration script at /usr/sadm/lib/smc/prereg/<PKG>/<PKG>_reg.sh
    ${SMCREG} library -n  VUserMgrLib.jar \
        ${ADMIN_LIBDIR}/usermgr/VUserMgrLib.jar \
	${ADMIN_LIBDIR}/usermgr/VUserMgrLib_classlist.txt ALL

fi

#
# This code was added for the fix for bugid 4750864.
#
WBEMINIT=${ROOTDIR}/etc/init.d/init.wbem
WBEMVAR=${ROOTDIR}/var/sadm/smc/codebase
USERMGR=${ROOTDIR}/usr/sadm/lib/usermgr

# If SMC repository doesn't exist, server was never started,
# so no need to update tools jars.  Instead, the
# tool's registration script will do the necessary updates.
if [ ! -d ${WBEMVAR} ]; then
    exit 0
fi

cp ${USERMGR}/UserMgrGroupCli.jar ${WBEMVAR}/tools/com.sun.admin.usermgr.cli.group.UserMgrGroupCli.jar
cp ${USERMGR}/UserMgrMailCli.jar  ${WBEMVAR}/tools/com.sun.admin.usermgr.cli.mail.UserMgrMailCli.jar
cp ${USERMGR}/VUserMgr.jar        ${WBEMVAR}/tools/com.sun.admin.usermgr.client.VUserMgr.jar
cp ${USERMGR}/VUserMgrLib.jar     ${WBEMVAR}/ALL@VUserMgrLib.jar

exit 0
