#!/bin/ksh
# Copyright 11/20/01 Sun Microsystems, Inc. All Rights Reserved.
# pragma ident  "@(#)es-cli	1.23 01/11/20 Sun Microsystems"

prog_base=`/usr/bin/basename $0`
common_cmd=`echo $0 | /usr/bin/sed s/$prog_base/es-common.sh/`
. $common_cmd

set_basedir
check_osver

checkJavaOK
if [ $? -ne 0 ] ; then
   [ -n "$JAVA_FULLVERSION" ] && echolog 'Found incomplete installation of $2' "$JAVA_FULLVERSION"
   echolog 'Sun Management Center requires complete installation of $2 or above.' "$JAVA_MINIMUM_REQUIRED"
   echolog 'Please follow the following steps before starting this component.'
   echolog '1. Install supported JDK version.'
   echolog '2. set JAVA_HOME to directory where JDK is installed.'
   echolog '3. export JAVA_HOME'
   echolog '4. Run $2' "$BASEDIR/sbin/es-setup"
   echolog ''
   /usr/bin/rm -f $JAVA_HOME_FILE
   exit 1
fi
SYMON_JAVAHOME=`/usr/bin/cat /var/opt/SUNWsymon/.java_home`

CLASSES=$BASEDIR/classes
APPSCLASSES=$BASEDIR/apps/classes
CLASSPATH=$CLASSES:$APPSCLASSES
CLASSPATH=$CLASSPATH:$CLASSES/xml/parser.jar
CLASSPATH=$CLASSPATH:$APPSCLASSES/escli.jar
CLASSPATH=$CLASSPATH:$CLASSES/esclt.jar
CLASSPATH=$CLASSPATH:$CLASSES/esjrm.jar
CLASSPATH=$CLASSPATH:$CLASSES/escom.jar
CLASSPATH=$CLASSPATH:$CLASSES/esmsg.jar
CLASSPATH=$CLASSPATH:$APPSCLASSES/escix.jar

if [ -z "$LD_LIBRARY_PATH" ]
then
	export LD_LIBRARY_PATH=$BASEDIR/base/lib
else
	export LD_LIBRARY_PATH=$BASEDIR/base/lib:${LD_LIBRARY_PATH}
fi

if [[ $1 = "-e" ]]
then
	shift 1
	$SYMON_JAVAHOME/bin/java -classpath $CLASSPATH com.sun.symon.base.cli.base.ClCLI << EOF
	$@
	exit
EOF
else
	$SYMON_JAVAHOME/bin/java -classpath $CLASSPATH com.sun.symon.base.cli.base.ClCLI $@
fi
