#!/bin/sh

SMCREG=${BASEDIR}/usr/sadm/bin/smcregister
WBEMINIT=${BASEDIR}/etc/init.d/init.wbem
ADMIN_LIBDIR=${BASEDIR}/usr/sadm/lib
VOLMGR_LIBDIR=${BASEDIR}/usr/snadm/lib
export BASEDIR

# 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 "${BASEDIR}/var/sadm/smc" ]; then
    exit 0
fi


# Register tools and services
if [ -f ${SMCREG} ]; then
    ${SMCREG} tool -n com.sun.admin.volmgr.client.VVolMgr.jar \
        ${ADMIN_LIBDIR}/volmgr/VVolMgr.jar \
	${ADMIN_LIBDIR}/volmgr/VVolMgr_classlist.txt \
	${ADMIN_LIBDIR}/volmgr/VVolMgrInfo.xml

    ${SMCREG} tool -n com.sun.admin.volmgr.services.SVMServices.jar \
        ${ADMIN_LIBDIR}/volmgr/SVMServices.jar \
        ${ADMIN_LIBDIR}/volmgr/SVMServices_classlist.txt \
        ${ADMIN_LIBDIR}/volmgr/SVMServicesInfo.xml \
	${VOLMGR_LIBDIR}/libsvmJNI.so
fi

# Restart SMC/WBEM server, if currently running.
running=`env LANG=C LC_ALL=C ${WBEMINIT} status | grep "not running"`
if [ -z "${running}" ]; then
    ${WBEMINIT} stop
    ${WBEMINIT} start
fi
