#
# @(#)vmprov.sh	1.86 02/13/04 10:53:15 - 
#
# Copyright © 2002 VERITAS Software Corporation. All Rights Reserved.
#
# THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND
# TRADE SECRETS OF VERITAS SOFTWARE.  USE, DISCLOSURE,
# OR REPRODUCTION IS PROHIBITED WITHOUT THE PRIOR
# EXPRESS WRITTEN PERMISSION OF VERITAS SOFTWARE CORPORATION
#
#               RESTRICTED RIGHTS LEGEND
# USE, DUPLICATION OR DISCLOSURE BY THE U.S. GOVERNMENT IS
# SUBJECT TO RESTRICTIONS SET FORTH IN
# THE VERITAS SOFTWARE CORPORATION LICENSE AGREEMENT AND AS
# PROVIDED IN DFARS 227.7202-1(a) and
# 227.7202-3(a) (1998), and FAR 12.212, as applicable.
# VERITAS Software Corporation
# 350 Ellis Street,
# Mountain View, CA 94043.
#
# UNPUBLISHED -- RIGHTS RESERVED UNDER THE COPYRIGHT
# LAWS OF THE UNITED STATES.  USE OF A COPYRIGHT NOTICE
# IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
# OR DISCLOSURE.
#
# vmprov.sh manual install/remove VM Provider script 
#
######################################################################
# globals for VRTSob package and VRTSvmpro package
######################################################################

message()
{
	$_ECHO "$@"
}

errmsg()
{
	$_ECHO "ERROR:   $@"
}

warning()
{
	$_ECHO "WARNING: $@"
}


note()
{
	$_ECHO "NOTE:    $@"
}


fatalexit()
{
	[ "$verbose" = "yes" ] && \
	     message "          Please fix the problem and re-run this script.\n"
	exit 1
}

usage()
{
	if [ "$prt_usage" = "yes" ]
	then
		message "Usage:  vmprov.sh [-f|v|p] { add | remove }\n"
		exit 1
	fi
}

getguid()
{
	SYMBOL=$1
	FILE=$2
	while read  guid
	do
		NAME=`$REGOPS queryvalue "$KEYC/$guid" SymbolicName 2>/dev/null | cut -c27-`
		if [ "$NAME" = "$SYMBOL" ] 
		then
			echo $guid
			return 0
		fi
	done < $FILE
	return 1
}

incr_version()
{
		integer_part=`echo $1|cut -f 1,3 -d .`
		decimal_part=`echo $1|sed -e "s/$integer_part\.//"`
		up_decimal_part=`expr $decimal_part + 1`
		echo "$integer_part.$up_decimal_part"
}

decr_version()
{

		integer_part=`echo $1|cut -f 1,3 -d .`
		decimal_part=`echo $1|sed -e "s/$integer_part\.//"`

		if [ $decimal_part != "0" ]
		then
			down_decimal_part=`expr $decimal_part - 1`
		else
			# This should never happen. Hoever wish we have started
			# the version at least at X.1 instead of X.0. 
			down_decimal_part=$decimal_part
		fi

		echo "$integer_part.$down_decimal_part"
}


add_objtypes()
{
	cp $PKG_INSTALL_ROOT/etc/vx/isis/objecttypes.dtd $OBDIR/bin
	cp $PKG_INSTALL_ROOT/etc/vx/isis/objecttypes.xml $OBDIR/bin
	cp $VMOBJFILE $OBDIR/bin
	
	CUR_DIR=`pwd`
	cd $OBDIR/bin

	$REGOPS $REGFILE setvalue Software/VERITAS/Vxsvc/CurrentVersion ObjectTypeDTD REG_SZ objecttypes.dtd

	TMPDIR=$OBDIR/bin
	export TMPDIR
	RANDFILE=$PKG_INSTALL_ROOT/var/vx/isis/.rand
	export RANDFILE

	$OBJTYPOPS -r $REGFILE -m $OBDIR/bin/vxvm.xml -i $OBDIR/bin/objecttypes.xml -o $OBDIR/bin/objecttypes.xml

	mv objecttypes.xml $PKG_INSTALL_ROOT/etc/vx/isis
	rm objecttypes.dtd
	rm vxvm.xml
	rm -f $PKG_INSTALL_ROOT/var/vx/isis/.rand
	cd $CUR_DIR

	$REGOPS $REGFILE setvalue Software/VERITAS/Vxsvc/CurrentVersion ObjectTypeDTD REG_SZ  /etc/vx/isis/objecttypes.dtd

	unset TMPDIR
}


##############################################################################
# function to register the vmprovider to VIP                                 #
##############################################################################

vmprov_remove_ext()
{
    guid=`getguid VxVmCE $TMPFILE`
    if [ "$guid" != "" ]
    then

       $REGOPS deletekeyrecursive $KEYC/$guid  2>/dev/null
    fi

    guid=`getguid VxVmHelp $TMPFILE`
    if [ "$guid" != "" ]
    then
       $REGOPS deletekeyrecursive $KEYC/$guid  2>/dev/null
    fi

    guid=`getguid VmResourceBundle $TMPFILE`
    if [ "$guid" != "" ]
    then
       $REGOPS deletekeyrecursive $KEYC/$guid  2>/dev/null
    fi

    guid=`getguid VmLibResourceBundle $TMPFILE`
    if [ "$guid" != "" ]
    then
       $REGOPS deletekeyrecursive $KEYC/$guid  2>/dev/null
    fi


    guid=`getguid VxVmOneguiResourceBundle $TMPFILE`
    if [ "$guid" != "" ]
    then
       $REGOPS deletekeyrecursive $KEYC/$guid  2>/dev/null
    fi

    guid=`getguid VxVmVxFsResourceBundle $TMPFILE`
    if [ "$guid" != "" ]
    then
       $REGOPS deletekeyrecursive $KEYC/$guid  2>/dev/null
    fi

    $REGOPS $REGFILE deletevalue $DDLKEY ClientExtension 2>/dev/null
}

vmprov_register()
{
    if [ ! -f $VMPRODIR/lib/vxvmprovider.$SHLIB_EXT ]
    then
	[ "$verbose" = "yes" -o "$prt_error_only" = "yes" ] && errmsg "VM provider installation terminated; this VM provider package does not
         contain a VM provider library for this version of VM.\n"
	fatalexit
    fi


    [ "$verbose" = "yes" ] && note "Adding VM provider to Enterprise Administrator Service registry file...\c"
    cp $REGFILE $REGFILE.pre-vmpro

    # make sure VxVmCE is really gone. so no dup entries in Registry
    $REGOPS $REGFILE enumkey $KEYC >$TMPFILE
    vmprov_remove_ext

#   remove old Search
    guid=`getguid SearchResourceBundle $TMPFILE`
    if [ "$guid" != "" ]
    then
       $REGOPS deletekeyrecursive $KEYC/$guid  2>/dev/null
    fi

    guid=`getguid VxSearchCE $TMPFILE`
    if [ "$guid" != "" ]
    then
       $REGOPS deletekeyrecursive $KEYC/$guid  2>/dev/null
    fi

    ##########################
    # adding the vmprovider library entry
    ##########################
    $REGOPS $REGFILE createkey $KEY
    $REGOPS $REGFILE setvalue $KEY ImageFile REG_SZ $VMPROBASE/lib/vxvmprovider.$SHLIB_EXT

    ##########################
    # subsequent provider installs can turn this off to avoid gui confusion.
    ##########################
    $REGOPS $REGFILE setvalue $KEY ClusterGroupNodeFlag REG_INT 1

    ##########################
    # adding the vmprovider log file, only add it if not set.
    ##########################
    CMDLOGKEY=Software/VERITAS/VxSvc/CurrentVersion
    CMDLOG=/var/vx/isis/command.log   
    $REGOPS $REGFILE queryvalue $CMDLOGKEY CommandLog > /dev/null 2>&1 
    if [ $? != 0 ] 
    then 
           mkdir -p $PKG_INSTALL_ROOT/`dirname $CMDLOG` 
           touch $PKG_INSTALL_ROOT/$CMDLOG 
           $REGOPS $REGFILE setvalue $CMDLOGKEY CommandLog REG_SZ $CMDLOG
    fi

    ##########################
    # make the tasks continue to appear after complete
    ##########################
    $REGOPS $REGFILE setvalue Software/VERITAS/VxSvc/CurrentVersion PersistTasks REG_INT 1

    ##########################
    # adding the vmprovider library security entry
    ##########################
    SECURITY_KEY=Software/VERITAS/VxSvc/CurrentVersion/Security
    ACCESSGROUPS="vrtsadm"

    $REGOPS $REGFILE queryvalue $SECURITY_KEY AccessUsers > /dev/null 2>&1 
    if [ $? != 0 ] 
    then 
	    $REGOPS $REGFILE createkey $SECURITY_KEY
	    $REGOPS $REGFILE setvalue $SECURITY_KEY AccessUsers REG_SZ ""
    fi

    $REGOPS $REGFILE queryvalue $SECURITY_KEY AccessGroups > /dev/null 2>&1 
    if [ $? != 0 ] 
    then 
	    $REGOPS $REGFILE createkey $SECURITY_KEY
	    $REGOPS $REGFILE setvalue $SECURITY_KEY AccessGroups REG_SZ $ACCESSGROUPS
    fi


    ##########################
    # adding a VM Provider dependency entry
    ##########################
    DEPENDENCY_KEY=Software/VERITAS/VxSvc/CurrentVersion/InstalledProducts
    DEPEND_VMPRO_KEY=$DEPENDENCY_KEY/VRTSvmpro
    $REGOPS $REGFILE createkey $DEPENDENCY_KEY
    $REGOPS $REGFILE createkey $DEPEND_VMPRO_KEY

    #########################
    # adding the client extension entries
    #########################
    $REGOPS $REGFILE setvalue $KEY ClientExtension REG_SZ {$CLIENT_EXT_VxVmCE}
    #
    #### VxVmCE.jar
    $REGOPS $REGFILE createkey $GUIKEY_VxVmCE
    $REGOPS $REGFILE setvalue $GUIKEY/{$CLIENT_EXT_VxVmCE} SymbolicName REG_SZ VxVmCE
    $REGOPS $REGFILE setvalue $GUIKEY_VxVmCE ImageFile REG_SZ $CLIENT_EXT_VXVM/VxVmCE.jar
    $REGOPS $REGFILE setvalue $GUIKEY_VxVmCE Version REG_SZ $VxVmCE_VERSION
    $REGOPS $REGFILE setvalue $GUIKEY_VxVmCE StrictDependsOn REG_SZ "VxVmHelp,VmResourceBundle,VmLibResourceBundle,VxSearchCE,VxVmOneguiResourceBundle,VxVmVxFsResourceBundle"
    #
    #### VxResourceBundle jars
    $REGOPS $REGFILE createkey $GUIKEY_VmResourceBundle
    $REGOPS $REGFILE setvalue $GUIKEY/{$CLIENT_EXT_VmResourceBundle} SymbolicName REG_SZ VmResourceBundle
    #
    $REGOPS $REGFILE createkey $GUIKEY_VmResourceBundle_en
    $REGOPS $REGFILE setvalue $GUIKEY_VmResourceBundle_en ImageFile REG_SZ $CLIENT_EXT_RESOURCE/VmResourceBundle.en.jar
    $REGOPS $REGFILE setvalue $GUIKEY_VmResourceBundle_en Version REG_SZ $VmResourceBundle_en_VERSION
    #
    #
    #### VxLibResourceBundle jars
    $REGOPS $REGFILE createkey $GUIKEY_VmLibResourceBundle
    $REGOPS $REGFILE setvalue $GUIKEY/{$CLIENT_EXT_VmLibResourceBundle} SymbolicName REG_SZ VmLibResourceBundle
    #
    $REGOPS $REGFILE createkey $GUIKEY_VmLibResourceBundle_en
    $REGOPS $REGFILE setvalue $GUIKEY_VmLibResourceBundle_en ImageFile REG_SZ $CLIENT_EXT_RESOURCE/VmLibResourceBundle.en.jar
    $REGOPS $REGFILE setvalue $GUIKEY_VmLibResourceBundle_en Version REG_SZ $VmLibResourceBundle_en_VERSION
    #
    #
    #### VxVmOneguiResourceBundle jars
    $REGOPS $REGFILE createkey $GUIKEY_VxVmOneguiResourceBundle
    $REGOPS $REGFILE setvalue $GUIKEY/{$CLIENT_EXT_VxVmOneguiResourceBundle} SymbolicName REG_SZ VxVmOneguiResourceBundle
    #
    $REGOPS $REGFILE createkey $GUIKEY_VxVmOneguiResourceBundle_en
    $REGOPS $REGFILE setvalue $GUIKEY_VxVmOneguiResourceBundle_en ImageFile REG_SZ $CLIENT_EXT_RESOURCE/VxVmOneguiResourceBundle.en.jar
    $REGOPS $REGFILE setvalue $GUIKEY_VxVmOneguiResourceBundle_en Version REG_SZ $VxVmOneguiResourceBundle_en_VERSION
    #
    #
    #### VxVmVxFsResourceBundle jars
    $REGOPS $REGFILE createkey $GUIKEY_VxVmVxFsResourceBundle
    $REGOPS $REGFILE setvalue $GUIKEY/{$CLIENT_EXT_VxVmVxFsResourceBundle} SymbolicName REG_SZ VxVmVxFsResourceBundle
    #
    $REGOPS $REGFILE createkey $GUIKEY_VxVmVxFsResourceBundle_en
    $REGOPS $REGFILE setvalue $GUIKEY_VxVmVxFsResourceBundle_en ImageFile REG_SZ $CLIENT_EXT_RESOURCE/VxVmVxFsResourceBundle.en.jar
    $REGOPS $REGFILE setvalue $GUIKEY_VxVmVxFsResourceBundle_en Version REG_SZ $VxVmVxFsResourceBundle_en_VERSION
    #
    #
    #### VxVmHelp.jar
    $REGOPS $REGFILE createkey $GUIKEY_VxVmHelp
    $REGOPS $REGFILE setvalue $GUIKEY/{$CLIENT_EXT_VxVmHelp} SymbolicName REG_SZ VxVmHelp
    $REGOPS $REGFILE setvalue $GUIKEY_VxVmHelp ImageFile REG_SZ $CLIENT_EXT_VXVM/VxVmHelp.en.jar
    $REGOPS $REGFILE setvalue $GUIKEY_VxVmHelp Version REG_SZ $VxVmHelp_en_VERSION
    #


##########################
# removing previous searchprovider and extension
##########################
if [ -f $OBDIR/lib/searchprovider.$SHLIB_EXT ]
then
   # look up current search guid and remove
   OLDGUID=`$REGOPS $REGFILE queryvalue $SKEY ClientExtension 2>/dev/null | cut -c30-`
   if [ $? = 0 ] 
   then
	if [ "$OLDGUID" != "" ]
	then
		$REGOPS deletekeyrecursive "$GUIKEY/$OLDGUID" >/dev/null 2>&1
	fi
   fi

#   remove old Search
    guid=`getguid SearchResourceBundle $TMPFILE`
    if [ "$guid" != "" ]
    then
       $REGOPS deletekeyrecursive $KEYC/$guid  2>/dev/null
    fi

    guid=`getguid VxSearchCE $TMPFILE`
    if [ "$guid" != "" ]
    then
       $REGOPS deletekeyrecursive $KEYC/$guid  2>/dev/null
    fi
fi

##########################
# adding the searchprovider library entry
##########################
$REGOPS $REGFILE createkey $SKEY
$REGOPS $REGFILE setvalue $SKEY ImageFile REG_SZ $OBBASE/lib/searchprovider.$SHLIB_EXT

$REGOPS $REGFILE setvalue $SKEY ClientExtension REG_SZ {$CLIENT_EXT_VxSearchCE}

#### VxSearchCE.jar
$REGOPS $REGFILE createkey $GUIKEY_VxSearchCE
$REGOPS $REGFILE setvalue $GUIKEY/{$CLIENT_EXT_VxSearchCE} SymbolicName REG_SZ VxSearchCE
$REGOPS $REGFILE setvalue $GUIKEY_VxSearchCE ImageFile REG_SZ $OBBASE/extensions/VxSearch/IsisSkin/java/1033/VxSearchCE.jar 
$REGOPS $REGFILE setvalue $GUIKEY_VxSearchCE Flags REG_INT 1
$REGOPS $REGFILE setvalue $GUIKEY_VxSearchCE Version REG_SZ $VxSearchCE_VERSION
$REGOPS $REGFILE setvalue $GUIKEY_VxSearchCE StrictDependsOn REG_SZ "SearchResourceBundle"

#
#### SearchResourceBundle jars
    $REGOPS $REGFILE createkey $GUIKEY_SearchResourceBundle
    $REGOPS $REGFILE setvalue $GUIKEY/{$CLIENT_EXT_SearchResourceBundle} SymbolicName REG_SZ SearchResourceBundle
    #
    $REGOPS $REGFILE createkey $GUIKEY_SearchResourceBundle_en
    $REGOPS $REGFILE setvalue $GUIKEY_SearchResourceBundle_en ImageFile REG_SZ $OBBASE/extensions/VxSearch/IsisSkin/java/1033/SearchResourceBundle.en.jar 
    $REGOPS $REGFILE setvalue $GUIKEY_SearchResourceBundle_en Version REG_SZ $SearchResourceBundle_en_VERSION


    [ "$verbose" = "yes" ] && message ""

    #############################
    #  don't know where to put the search provider so put it in the VIP 
    #  library area
    #  don't know where to put the search CE so put it in the VIP 
    #  extensions area
    #############################
    #[ "$verbose" = "yes" ] && \
    #		note "Installing searchprovider.$SHLIB_EXT"

    cp -f $VMPRODIR/lib/searchprovider.$SHLIB_EXT $OBDIR/lib/searchprovider.$SHLIB_EXT

    [ ! -d $OBDIR/extensions/VxSearch/IsisSkin/java/1033 ] && \
    	mkdir -p $OBDIR/extensions/VxSearch/IsisSkin/java/1033 2>/dev/null
    cp $VMPRODIR/extensions/VxSearchCE.jar \
	    $OBDIR/extensions/VxSearch/IsisSkin/java/1033/VxSearchCE.jar

    cp $VMPRODIR/extensions/SearchResourceBundle.en.jar \
	    $OBDIR/extensions/VxSearch/IsisSkin/java/1033/SearchResourceBundle.en.jar


    if [ "$debug" = "yes" ]
    then		
	[ "$verbose" = "yes" ] && \
		note "Setting the VM Provider debug output to enabled...\c"
	$REGOPS $REGFILE setvalue $KEY debug REG_SZ yes 
    	[ "$verbose" = "yes" ] && message ""
    fi

    [ "$verbose" = "yes" ] && \
    note "Adding VM objects to VERITAS Enterprise Administrator Service...\c"

    if [ "$OS_PLAT" = "SunOS" ]
    then
	    add_objtypes
    else
	$OBJTYPOPS -r $REGFILE -m $VMOBJFILE -i $PKG_INSTALL_ROOT/etc/vx/isis/objecttypes.xml -o $PKG_INSTALL_ROOT/etc/vx/isis/objecttypes.xml
    fi

    [ "$verbose" = "yes" ] && message ""

    [ "$verbose" = "yes" ] && \
	note "To use the VM Provider you must restart the VERITAS Enterprise Administrator
         Service server.  Refer to the man page for vxsvc(1M)."

    [ "$verbose" = "yes" ] && message ""
    [ "$verbose" = "yes" ] && \
		note "VM provider configuration installation complete.\n"
}

vmprov_unregister()
{
    #
    # update Enterprise Administrator Service Registry file to remove 
    # VM provider configuration info.
    #

    if [ ! -x $REGOPS -o ! -x $OBJTYPOPS -o ! -f $REGFILE ] 
    then
	[ "$verbose" = "yes" -o "$prt_error_only" = "yes" ] && errmsg "Cannot locate the VERITAS Enterprise Administrator Service utilities.  
         Please fix this problem and then reattempt this configuration removal.
 
         Aborting VM provider configuration installation attempt."
	exit 3
    fi

    # Remove the registry entries that had been created at the time of
    # postinstall.
    [ "$verbose" = "yes" ] && note "Removing the VM provider from VERITAS Enterprise Administrator Service Registry...\c"

    ##############################
    # remove the vm provider library entry
    ##############################
    $REGOPS $REGFILE deletekey $KEY 2>/dev/null


    ##############################
    # remove the client extensions entries
    ##############################
    #
    #### VxVmCE.jar
    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VxVmCE}/IsisSkin/1/1033 ImageFile 2>/dev/null
    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VxVmCE}/IsisSkin/1/1033 StrictDependsOn 2>/dev/null
    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VxVmCE}/IsisSkin/1/1033 Version 2>/dev/null
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VxVmCE}/IsisSkin/1/1033 2>/dev/null
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VxVmCE}/IsisSkin/1 2>/dev/null
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VxVmCE}/IsisSkin 2>/dev/null
    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VxVmCE} SymbolicName 2>/dev/null
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VxVmCE} 2>/dev/null

    #
    #### VmResourceBundle jars
    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VmResourceBundle}/IsisSkin/1/1033 ImageFile 2>/dev/null
    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VmResourceBundle}/IsisSkin/1/1033 Version 2>/dev/null
    #
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VmResourceBundle}/IsisSkin/1/1033 2>/dev/null
    #
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VmResourceBundle}/IsisSkin/1 2>/dev/null
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VmResourceBundle}/IsisSkin 2>/dev/null
    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VmResourceBundle} SymbolicName 2>/dev/null
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VmResourceBundle} 2>/dev/null

    #
    #### VmLibResourceBundle jars
    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VmLibResourceBundle}/IsisSkin/1/1033 ImageFile 2>/dev/null
    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VmLibResourceBundle}/IsisSkin/1/1033 Version 2>/dev/null
    #
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VmLibResourceBundle}/IsisSkin/1/1033 2>/dev/null
    #
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VmLibResourceBundle}/IsisSkin/1 2>/dev/null
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VmLibResourceBundle}/IsisSkin 2>/dev/null
    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VmLibResourceBundle} SymbolicName 2>/dev/null
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VmLibResourceBundle} 2>/dev/null

    #
    #### VxVmOneguiResourceBundle jars
    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VxVmOneguiResourceBundle}/IsisSkin/1/1033 ImageFile 2>/dev/null
    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VxVmOneguiResourceBundle}/IsisSkin/1/1033 Version 2>/dev/null
    #
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VxVmOneguiResourceBundle}/IsisSkin/1/1033 2>/dev/null
    #
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VxVmOneguiResourceBundle}/IsisSkin/1 2>/dev/null
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VxVmOneguiResourceBundle}/IsisSkin 2>/dev/null
    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VxVmOneguiResourceBundle} SymbolicName 2>/dev/null
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VxVmOneguiResourceBundle} 2>/dev/null

    #
    #### VxVmVxFsResourceBundle jars
    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VxVmVxFsResourceBundle}/IsisSkin/1/1033 ImageFile 2>/dev/null
    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VxVmVxFsResourceBundle}/IsisSkin/1/1033 Version 2>/dev/null
    #
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VxVmVxFsResourceBundle}/IsisSkin/1/1033 2>/dev/null
    #
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VxVmVxFsResourceBundle}/IsisSkin/1 2>/dev/null
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VxVmVxFsResourceBundle}/IsisSkin 2>/dev/null
    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VxVmVxFsResourceBundle} SymbolicName 2>/dev/null
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VxVmVxFsResourceBundle} 2>/dev/null

    #
    #
    #### VxVmHelp.jar
    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VxVmHelp}/IsisSkin/1/1033 ImageFile 2>/dev/null
    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VxVmHelp}/IsisSkin/1/1033 Version 2>/dev/null
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VxVmHelp}/IsisSkin/1/1033 2>/dev/null
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VxVmHelp}/IsisSkin/1 2>/dev/null
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VxVmHelp}/IsisSkin 2>/dev/null
    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VxVmHelp} SymbolicName 2>/dev/null
    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VxVmHelp} 2>/dev/null
    #
   	
#    ##############################
#    # remove the searchprovider library entry
#    ##############################
#    $REGOPS $REGFILE deletekey $SKEY 2>/dev/null
#    #
#    #### VxSearchCE.jar
#    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VxSearchCE}/IsisSkin/1/1033 ImageFile 2>/dev/null
#    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VxSearchCE}/IsisSkin/1/1033 Flags 2>/dev/null
#    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VxSearchCE}/IsisSkin/1/1033 Version 2>/dev/null
#    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VxSearchCE}/IsisSkin/1/1033 2>/dev/null
#    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VxSearchCE}/IsisSkin/1 2>/dev/null
#    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VxSearchCE}/IsisSkin 2>/dev/null
#    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_VxSearchCE} SymbolicName 2>/dev/null
#    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_VxSearchCE} 2>/dev/null
#    #


#### SearchResourceBundle jars
#    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_SearchResourceBundle}/IsisSkin/1/1033 ImageFile 2>/dev/null
#    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_SearchResourceBundle}/IsisSkin/1/1033 Version 2>/dev/null
#    #
#    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_SearchResourceBundle}/IsisSkin/1/1033 2>/dev/null
#    #
#    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_SearchResourceBundle}/IsisSkin/1 2>/dev/null
#    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_SearchResourceBundle}/IsisSkin 2>/dev/null
#    $REGOPS $REGFILE deletevalue $KEYC/{$CLIENT_EXT_SearchResourceBundle} SymbolicName 2>/dev/null
#    $REGOPS $REGFILE deletekey $KEYC/{$CLIENT_EXT_SearchResourceBundle} 2>/dev/null



    ##############################
    # remove the vm provider dependency entry
    ##############################
    DEPENDENCY_KEY=Software/VERITAS/VxSvc/CurrentVersion/InstalledProducts
    DEPEND_VMPRO_KEY=$DEPENDENCY_KEY/VRTSvmpro
    $REGOPS $REGFILE deletekey $DEPEND_VMPRO_KEY 2>/dev/null


    [ "$verbose" = "yes" ] && message ""

    [ "$verbose" = "yes" ] && note "Removing VM objects from VERITAS Enterprise Administrator Service Registry file...\c"
    $OBJTYPOPS -d -F $VMOBJFILE 2>/dev/null
    [ "$verbose" = "yes" ] && message ""

    [ "$verbose" = "yes" ] && \
		note "Removing VRTSvmpro files under $PKG_INSTALL_ROOT/etc/vx/isis...\c"
    rm -rf $PKG_INSTALL_ROOT/etc/vx/isis/Registry.pre-vmpro
    [ "$verbose" = "yes" ] && message ""

    [ "$verbose" = "yes" ] && message ""
    [ "$verbose" = "yes" ] && \
		note "VM provider configuration removal complete.\n"
}



###############################################
# function to patchadd the vm provider to VEA #
###############################################
vmprov_patchadd()
{
    if [ ! -f $VMPRODIR/lib/vxvmprovider.$SHLIB_EXT ]
    then
	[ "$verbose" = "yes" -o "$prt_error_only" = "yes" ] && errmsg "VM provider patchadd terminated; this VM provider package does not
         contain a VM provider library for this version of VM.\n"
	fatalexit
    fi

    if [ ! -x $REGOPS -o ! -x $OBJTYPOPS -o ! -f $REGFILE ] 
    then
	[ "$verbose" = "yes" -o "$prt_error_only" = "yes" ] && errmsg "Cannot locate the VERITAS Enterprise Administrator Service utilities.  
         Please fix this problem and then reattempt this configuration removal.
 
         Aborting VM provider patchadd attempt."
	exit 3
    fi


    [ "$verbose" = "yes" ] && \
		note "Adding VRTSvmpro patch in VEA Registry ... \c"

    cp $REGFILE $REGFILE.pre-vmpro

    $REGOPS $REGFILE enumkey $KEYC >$TMPFILE
    SKIN=IsisSkin/1/1033
    ######################
    # Increment versions of the client extension entries
    ######################
    #
    #### VxVmCE.jar
    guid=`getguid VxVmCE $TMPFILE`
    ver=`$REGOPS $REGFILE queryvalue $KEYC/$guid/$SKIN Version 2>/dev/null | awk '{print $5}'`
    incr=`incr_version $ver`
    $REGOPS $REGFILE setvalue $KEYC/$guid/$SKIN Version REG_SZ $incr

    #### VM Help
    guid=`getguid VxVmHelp $TMPFILE`
    ver=`$REGOPS $REGFILE queryvalue $KEYC/$guid/$SKIN Version 2>/dev/null | awk '{print $5}'`
    incr=`incr_version $ver`
    $REGOPS $REGFILE setvalue $KEYC/$guid/$SKIN Version REG_SZ $incr

    #### VM Resource Bundles
    guid=`getguid VmResourceBundle $TMPFILE`
    ver=`$REGOPS $REGFILE queryvalue $KEYC/$guid/$SKIN Version 2>/dev/null | awk '{print $5}'`
    incr=`incr_version $ver`
    $REGOPS $REGFILE setvalue $KEYC/$guid/$SKIN Version REG_SZ $incr

    guid=`getguid VmLibResourceBundle $TMPFILE`
    ver=`$REGOPS $REGFILE queryvalue $KEYC/$guid/$SKIN Version 2>/dev/null | awk '{print $5}'`
    incr=`incr_version $ver`
    $REGOPS $REGFILE setvalue $KEYC/$guid/$SKIN Version REG_SZ $incr


    guid=`getguid VxVmOneguiResourceBundle $TMPFILE`
    ver=`$REGOPS $REGFILE queryvalue $KEYC/$guid/$SKIN Version 2>/dev/null | awk '{print $5}'`
    incr=`incr_version $ver`
    $REGOPS $REGFILE setvalue $KEYC/$guid/$SKIN Version REG_SZ $incr


    guid=`getguid VxVmVxFsResourceBundle $TMPFILE`
    ver=`$REGOPS $REGFILE queryvalue $KEYC/$guid/$SKIN Version 2>/dev/null | awk '{print $5}'`
    incr=`incr_version $ver`
    $REGOPS $REGFILE setvalue $KEYC/$guid/$SKIN Version REG_SZ $incr


    #### VxSearchCE.jar
    guid=`getguid VxSearchCE $TMPFILE`
    ver=`$REGOPS $REGFILE queryvalue $KEYC/$guid/$SKIN Version 2>/dev/null | awk '{print $5}'`
    incr=`incr_version $ver`
    $REGOPS $REGFILE setvalue $KEYC/$guid/$SKIN Version REG_SZ $incr


    #### Search Resource Bundles
    guid=`getguid SearchResourceBundle $TMPFILE`
    ver=`$REGOPS $REGFILE queryvalue $KEYC/$guid/$SKIN Version 2>/dev/null | awk '{print $5}'`
    incr=`incr_version $ver`
    $REGOPS $REGFILE setvalue $KEYC/$guid/$SKIN Version REG_SZ $incr


    #### Message Catalogs
#    guid=`getguid $VMMSGKEY $TMPFILE`
#    ver=`$REGOPS $REGFILE queryvalue $KEYC/$guid/$SKIN Version 2>/dev/null | awk '{print $5}'`
#    if [ $ver != "" ]
#    then
#	    incr=`incr_version $ver`
#	    $REGOPS $REGFILE setvalue $KEYC/$guid/$SKIN Version REG_SZ $incr
#    fi

     echo

    cp -f $VMPRODIR/lib/searchprovider.$SHLIB_EXT $OBDIR/lib/searchprovider.$SHLIB_EXT

    [ ! -d $OBDIR/extensions/VxSearch/IsisSkin/java/1033 ] && \
    	mkdir -p $OBDIR/extensions/VxSearch/IsisSkin/java/1033 2>/dev/null
    cp $VMPRODIR/extensions/VxSearchCE.jar \
	    $OBDIR/extensions/VxSearch/IsisSkin/java/1033/VxSearchCE.jar

    cp $VMPRODIR/extensions/SearchResourceBundle.en.jar \
	    $OBDIR/extensions/VxSearch/IsisSkin/java/1033/SearchResourceBundle.en.jar

}

###############################################
# function to patch rm the vm provider to VEA #
###############################################

vmprov_patchrm()
{
    if [ ! -f $VMPRODIR/lib/vxvmprovider.$SHLIB_EXT ]
    then
	[ "$verbose" = "yes" -o "$prt_error_only" = "yes" ] && errmsg "VM provider patchrm terminated; this VM provider package does not
         contain a VM provider library for this version of VM.\n"
	fatalexit
    fi

    if [ ! -x $REGOPS -o ! -x $OBJTYPOPS -o ! -f $REGFILE ] 
    then
	[ "$verbose" = "yes" -o "$prt_error_only" = "yes" ] && errmsg "Cannot locate the VERITAS Enterprise Administrator Service utilities.  
         Please fix this problem and then reattempt this configuration removal.
 
         Aborting VM provider patchrm attempt."
	exit 3
    fi


    [ "$verbose" = "yes" ] && \
		note "Removing VRTSvmpro patch from VEA Registry ... \c"

    cp $REGFILE $REGFILE.pre-vmpro

    $REGOPS $REGFILE enumkey $KEYC >$TMPFILE
    SKIN=IsisSkin/1/1033

    ######################
    # decrement versions of the client extension entries
    ######################

    #### VxVmCE.jar
    guid=`getguid VxVmCE $TMPFILE`
    ver=`$REGOPS $REGFILE queryvalue $KEYC/$guid/$SKIN Version 2>/dev/null | awk '{print $5}'`
    decr=`decr_version $ver`
    $REGOPS $REGFILE setvalue $KEYC/$guid/$SKIN Version REG_SZ $decr

    #### VM Help
    guid=`getguid VxVmHelp $TMPFILE`
    ver=`$REGOPS $REGFILE queryvalue $KEYC/$guid/$SKIN Version 2>/dev/null | awk '{print $5}'`
    decr=`decr_version $ver`
    $REGOPS $REGFILE setvalue $KEYC/$guid/$SKIN Version REG_SZ $decr

    #### VM Resource Bundles
    guid=`getguid VmResourceBundle $TMPFILE`
    ver=`$REGOPS $REGFILE queryvalue $KEYC/$guid/$SKIN Version 2>/dev/null | awk '{print $5}'`
    decr=`decr_version $ver`
    $REGOPS $REGFILE setvalue $KEYC/$guid/$SKIN Version REG_SZ $decr

    guid=`getguid VmLibResourceBundle $TMPFILE`
    ver=`$REGOPS $REGFILE queryvalue $KEYC/$guid/$SKIN Version 2>/dev/null | awk '{print $5}'`
    decr=`decr_version $ver`
    $REGOPS $REGFILE setvalue $KEYC/$guid/$SKIN Version REG_SZ $decr


    guid=`getguid VxVmOneguiResourceBundle $TMPFILE`
    ver=`$REGOPS $REGFILE queryvalue $KEYC/$guid/$SKIN Version 2>/dev/null | awk '{print $5}'`
    decr=`decr_version $ver`
    $REGOPS $REGFILE setvalue $KEYC/$guid/$SKIN Version REG_SZ $decr


    guid=`getguid VxVmVxFsResourceBundle $TMPFILE`
    ver=`$REGOPS $REGFILE queryvalue $KEYC/$guid/$SKIN Version 2>/dev/null | awk '{print $5}'`
    decr=`decr_version $ver`
    $REGOPS $REGFILE setvalue $KEYC/$guid/$SKIN Version REG_SZ $decr


    guid=`getguid VxSearchCE  $TMPFILE`
    ver=`$REGOPS $REGFILE queryvalue $KEYC/$guid/$SKIN Version 2>/dev/null | awk '{print $5}'`
    decr=`decr_version $ver`
    $REGOPS $REGFILE setvalue $KEYC/$guid/$SKIN Version REG_SZ $decr

    guid=`getguid SearchResourceBundle  $TMPFILE`
    ver=`$REGOPS $REGFILE queryvalue $KEYC/$guid/$SKIN Version 2>/dev/null | awk '{print $5}'`
    decr=`decr_version $ver`
    $REGOPS $REGFILE setvalue $KEYC/$guid/$SKIN Version REG_SZ $decr


    #### Message Catalogs
#    guid=`getguid $VMMSGKEY $TMPFILE`
#    ver=`$REGOPS $REGFILE queryvalue $KEYC/$guid/$SKIN Version 2>/dev/null | awk '{print $5}'`
#    if [ $ver != "" ]
#    then
#	    decr=`decr_version $ver`
#	    $REGOPS $REGFILE setvalue $KEYC/$guid/$SKIN Version REG_SZ $decr
#    fi

     echo
}


set_echo()
{
	case $OS_PLAT in
	SunOS | Solaris)
		_ECHO="echo"	
		;;		
	AIX | aix)
		_ECHO="echo"	
		;;		
	HP-UX | hpux)
		_ECHO="echo"	
		;;		
	Linux | linux)
		_ECHO="echo -e"	
		;;		
	esac	
}


###########################################################################
###  main()
###########################################################################
force=no
verbose=no
debug=no
prt_usage=yes
prt_error_only=yes
_ECHO="echo"

set_echo

if [ $# -lt 1 ]
then
	usage
	exit 1
fi

while getopts :fFvVdDpPqQeE c
do
        case $c in
        f|F)    force=yes	
		;;
        v|V)    verbose=yes
		;;
        d|D)    debug=yes
		;;
        p|P)    prt_usage=no; verbose=yes; prt_error_only=yes 
		;;
        q|E)    prt_usage=no; verbose=no; prt_error_only=no 
		;;
        e|E)    prt_usage=no; verbose=no; prt_error_only=yes 
		;;
        ?)      usage; exit 1           
		;;
        esac
done

shift `expr $OPTIND - 1`
if [ $# -ne 1 ]
then
	usage  
	exit 1
fi

option=$1
if [ -z "$option" ]
then
	usage
	exit 1
fi


case $option in
	add)		action=add	;;
	remove)		action=remove	;;
	patchadd) 	action=patchadd	;;
	patchrm) 	action=patchrm	;;
	*)      	usage; exit 1	;;
esac


    #############################################
    # VERITAS Enterprise Administrator Service registry file paramaters
    #############################################

    OS_PLAT=`uname -s`

    # BASEDIR not defined for SunOS patchrm
    if [ "$OS_PLAT" = "SunOS" -a "$option" = "patchrm" ]
    then
	PKG_INSTALL_ROOT=$ROOTDIR
	BASEDIR=$ROOTDIR/opt
    fi

    if [ -z "$BASEDIR" -o "$OS_PLAT" = "AIX" ]
    then
	BASEDIR=/opt
    fi
    OBDIR=$BASEDIR/VRTSob
    VMPRODIR=$BASEDIR/VRTSvmpro

    VMPROBASE=/opt/VRTSvmpro
    OBBASE=/opt/VRTSob

    LD_LIBRARY_PATH=$OBDIR/lib:$LD_LIBRARY_PATH
    export LD_LIBRARY_PATH


    TMPFILE=/tmp/_vmpro_guids_
    SHLIB_EXT=so
    if [ "$OS_PLAT" = "HP-UX" ]; then SHLIB_EXT=sl; fi
    REGOPS=$OBDIR/bin/vxregctl
    OBJTYPOPS=$OBDIR/bin/vxobjecttype
    REGFILE=$PKG_INSTALL_ROOT/etc/vx/isis/Registry
    VMOBJFILE=$VMPRODIR/config/vxvm.xml
    KEY=Software/VERITAS/VxSvc/CurrentVersion/Providers/vxvmprovider
    SKEY=Software/VERITAS/VxSvc/CurrentVersion/Providers/searchprovider
    KEYC=Software/VERITAS/VxSvc/CurrentVersion/ClientExtensions

    if [ ! -x $REGOPS -o ! -x $OBJTYPOPS -o ! -f $REGFILE ] 
    then
	[ "$verbose" = "yes" -o "$prt_error_only" = "yes" ] && errmsg "Cannot locate the VERITAS Enterprise Administrator Service utilities.  
         Please fix this problem and then reattempt this configuration removal.
 
         Aborting VM provider configuration installation attempt."
	exit 3
    fi


###################################
#
#  client extension GUID
#
###################################

#
VxSearchCE_VERSION="1.5"
SearchResourceBundle_en_VERSION="1.5"
CLIENT_EXT_VxSearchCE="27312042-1dd2-11b2-840a-080020a6bb38"
CLIENT_EXT_SearchResourceBundle="eba32058-1dd1-11b2-840b-080020a6bb38"

#
VxVmCE_VERSION="1.1"
VxVmHelp_en_VERSION="1.1"
VmResourceBundle_en_VERSION="1.1"
VmLibResourceBundle_en_VERSION="1.1"
VxVmOneguiResourceBundle_en_VERSION="1.1"
VxVmVxFsResourceBundle_en_VERSION="1.1"

CLIENT_EXT_VxVmCE="81d9dbdc-1dd2-11b2-b0a8-b7fd9d58807c"
CLIENT_EXT_VxVmHelp="81dff468-1dd2-11b2-b236-b0e51077563b"
CLIENT_EXT_VmResourceBundle="81e6e728-1dd2-11b2-b3f1-b42a2421895b"
CLIENT_EXT_VmLibResourceBundle="81eebd72-1dd2-11b2-9340-a357ba60bdb0"
CLIENT_EXT_VxVmOneguiResourceBundle="81f4d900-1dd2-11b2-849f-668503495875"
CLIENT_EXT_VxVmVxFsResourceBundle="81fcac2a-1dd2-11b2-a75c-55b29908fabf"

#%NEW_GUIDS


    #############################
    # client extension paramaters
    #############################
    CLIENT_EXT_VXVM=$VMPROBASE/extensions
    CLIENT_EXT_RESOURCE=$VMPROBASE/extensions
    #
    GUIKEY=Software/VERITAS/VxSvc/CurrentVersion/ClientExtensions
   
    #### VxVmCE.jar
    GUIKEY_VxVmCE=Software/VERITAS/VxSvc/CurrentVersion/ClientExtensions/{$CLIENT_EXT_VxVmCE}/IsisSkin/1/1033
    #
    #### VxVmHelp
    GUIKEY_VxVmHelp=Software/VERITAS/VxSvc/CurrentVersion/ClientExtensions/{$CLIENT_EXT_VxVmHelp}/IsisSkin/1/1033
    #
    #### VmResourceBundle
    GUIKEY_VmResourceBundle=Software/VERITAS/VxSvc/CurrentVersion/ClientExtensions/{$CLIENT_EXT_VmResourceBundle}
    #
    # VmResourceBundle_xx.jar
    GUIKEY_VmResourceBundle_en=Software/VERITAS/VxSvc/CurrentVersion/ClientExtensions/{$CLIENT_EXT_VmResourceBundle}/IsisSkin/1/1033
    #	
    #### VmLibResourceBundle
    GUIKEY_VmLibResourceBundle=Software/VERITAS/VxSvc/CurrentVersion/ClientExtensions/{$CLIENT_EXT_VmLibResourceBundle}
    #
    # VmLibResourceBundle_xx.jar
    GUIKEY_VmLibResourceBundle_en=Software/VERITAS/VxSvc/CurrentVersion/ClientExtensions/{$CLIENT_EXT_VmLibResourceBundle}/IsisSkin/1/1033
    #
    #### VxVmOneguiResourceBundle
    GUIKEY_VxVmOneguiResourceBundle=Software/VERITAS/VxSvc/CurrentVersion/ClientExtensions/{$CLIENT_EXT_VxVmOneguiResourceBundle}
    #
    # VxVmOneguiResourceBundle_xx.jar
    GUIKEY_VxVmOneguiResourceBundle_en=Software/VERITAS/VxSvc/CurrentVersion/ClientExtensions/{$CLIENT_EXT_VxVmOneguiResourceBundle}/IsisSkin/1/1033
    #
    #### VxVmVxFsResourceBundle
    GUIKEY_VxVmVxFsResourceBundle=Software/VERITAS/VxSvc/CurrentVersion/ClientExtensions/{$CLIENT_EXT_VxVmVxFsResourceBundle}
    #
    # VxVmVxFsResourceBundle_xx.jar
    GUIKEY_VxVmVxFsResourceBundle_en=Software/VERITAS/VxSvc/CurrentVersion/ClientExtensions/{$CLIENT_EXT_VxVmVxFsResourceBundle}/IsisSkin/1/1033

    #### VxSearchCE
    GUIKEY_VxSearchCE=Software/VERITAS/VxSvc/CurrentVersion/ClientExtensions/{$CLIENT_EXT_VxSearchCE}/IsisSkin/1/1033

    #### SearchResourceBundle
    GUIKEY_SearchResourceBundle=Software/VERITAS/VxSvc/CurrentVersion/ClientExtensions/{$CLIENT_EXT_SearchResourceBundle}
    #
    # SearchResourceBundle_xx.jar
    GUIKEY_SearchResourceBundle_en=Software/VERITAS/VxSvc/CurrentVersion/ClientExtensions/{$CLIENT_EXT_SearchResourceBundle}/IsisSkin/1/1033




###################################
#
# add VM provider config
#
###################################
if [ "$option" = "add" ]
then
    set_echo	
    if [ "$force" = "no" ]
    then
    	case $OS_PLAT in
    	SunOS | Solaris)
	    ### test for "if pkginfo -q VRTSob" or "if pkginfo -q VRTSobdev"
	    OBPKG=0
	    OBDEVPKG=0

	    if [ -n "$PKG_INSTALL_ROOT" ]; then
                PKGINFO="pkginfo -R $PKG_INSTALL_ROOT"
            else
                PKGINFO="pkginfo"
            fi

	    $PKGINFO -q VRTSob > /dev/null 2>&1
	    if [ $? = 0 ]
	    then
		OBPKG=1
	    fi
	    $PKGINFO -q VRTSobdev > /dev/null 2>&1
	    if [ $? = 0 ]
	    then
		OBDEVPKG=1
	    fi

	    VXSVC=$OBDIR/bin/vxsvc
	    if [ \( \( "$OBPKG" -eq 1 \) -o \( "$OBDEVPKG" -eq 1 \) \) -a \( -f $VXSVC \) ]
	    then
		[ "$verbose" = "yes" ] && message ""
	    else
		[ "$verbose" = "yes" ] && errmsg "This installation attempt detected that the
         VERITAS Enterprise Administrator Service package (VRTSob) is not installed on this host.

         You must first install the VERITAS Enterprise Administrator Service
         (VRTSob)package before installing this VM provider (VRTSvmpro) package.

         This installation attempt of the VM provider package (VRTSvmpro) will
         now be aborted.\n"
		fatalexit
	    fi
	    ##############
	    # VRTSob or VRTSobdev is installed, so continue with the VRTSvmprov
	    # package installation
	    ##############
	    ;;		

	AIX | aix)
	    #
	    # prerequisite packaging checks are done via the AIX packaging
	    # facilities	
	    #
	    OBDIR=/opt/VRTSob
	    VXSVC=$OBDIR/bin/vxsvc

	    ##############
	    # VRTSob is installed, so continue with VRTSvmprov pkg install
	    ##############
	    ;;		

	HP-UX | hpux)
	    #
	    # prerequisite packaging checks are done via the HP packaging
	    # facilities	
	    #
	    OBDIR=/opt/VRTSob
	    VXSVC=$OBDIR/bin/vxsvc
	    ;;		

	Linux | linux)
	    #
	    # Perform checkinstall processing for the VERITAS Enterprise 
	    # Administrator Service package (VRTSob), and VERITAS Volume 
	    # Manager pkg (VRTSvxvm)
	    #
	    
	    # basedir of the VRTSob package
	    #
	    OBDIR=/opt/VRTSob

	    VXSVC=$OBDIR/bin/vxsvc
	    if [ -f $VXSVC ]
	    then
		[ "$verbose" = "yes" ] && message ""
	    else
		[ "$verbose" = "yes" ] && errmsg "This installation attempt detected that the VERITAS Enterprise Administrator
         Service package (VRTSob) is not installed on this host.

         You must first install the VERITAS Enterprise Administrator Service (VRTSob)
         package before installing this VM provider (VRTSvmpro) package.

         This installation attempt of the VM provider package (VRTSvmpro) will
         now be aborted.\n"
		fatalexit
	    fi

	    ##############
	    # VRTSob is installed, so continue with VRTSvmprov pkg install
	    ##############
	    ;;		

	esac	
    fi	# force = no


    #############################################
    # register the vmprovider to VIP 
    #############################################
    vmprov_register

fi   # add	


###################################
#
# remove VM provider config
#
###################################
if [ "$option" = "remove" ]
then
    set_echo

    # Perform preremove processing for the VRTSvmpro package.

    #############################################
    # un-register the vmprovider to VIP 
    #############################################
    vmprov_unregister
 
fi   # remove




if [ "$option" = "patchadd" ]
then
    set_echo

    # Perform preremove processing for the VRTSvmpro package.
    #############################################
    # add patch the vmprovider to VIP 
    #############################################
    vmprov_patchadd
 
fi   # patchadd


if [ "$option" = "patchrm" ]
then
    set_echo

    #############################################
    # remove patch the vmprovider to VIP 
    #############################################
    vmprov_patchrm
 
fi   # patchrm



rm -f $TMPFILE

exit 0
