#!/bin/ksh
#
# ident "@(#)smcwbemserver.sh	1.16 01/05/21 SMI"
# Copyright (c) 2000 Sun Microsystems, Inc.
# All Rights Reserved.

. ${VIPER_HOME}/lib/functions

# add WBEM CLASSPATH and LD_LIBRARY_PATH
# we have to find out where WBEM stuff resides
# 1) if this is run from workspace
# 2) if this is run from toolkit
# 3) if this is run from installed packages..(most likely)
#
# Right now we force user to have /usr/sadm/lib/wbem dir with
# appropriate jars and libs in place.

WBSERHOME=${WBBASEDIR:-/}usr/sadm
WBSERLIB=${WBSERHOME}/lib/wbem

LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${WBSERLIB}:/usr/snadm/lib
PATH=${PATH}:/usr/sbin

CLASSPATH=${WBSERLIB}:${VIPER_JSDK}:${JARPATH}/smcwbemserver_rt.jar:${SERVER_RT}:${CLASSPATH}:${WBSERLIB}/solarisprovider.jar:${WBSERLIB}/prodregapi.jar:${WBSERLIB}/jini-core.jar:${WBSERLIB}/jini-ext.jar:${WBSERLIB}/outrigger.jar:${WBSERLIB}/transient-outrigger.jar:${WBSERLIB}/cimrepository.jar:${WBSERLIB}/snmpprovider.jar:${WBSERLIB}/wbemsnmprt12.jar:${WBSERLIB}/nativeprovider.jar

umask 022

${JAVA} "${JAVAARGS[@]}" \
	-Djava.security.policy=${VIPER_HOME}/policy/smcwbemserver.policy \
	-Dviper.argv0=$0 \
	-Dviper.home=${VIPER_HOME} \
	-Dviper.rthome=${SMC_RTHOME} \
	-Dviper.display=${X_DISPLAY} \
	-Dpropdir=${WBSERLIB} \
	com.sun.management.viperimpl.server.ViperWbemServer "$@" |&

while true; do
	sIFS="$IFS"
	IFS="
"
	read -p bkg
	[ $? -ne 0 ] && exit 1
	IFS="sIFS"
	if expr "$bkg" : '^[0-9]$' > /dev/null 2>&1; then
		code=$bkg
		break
	fi
	echo "$bkg"
done

exit $code
