#!/bin/sh 

# 
#  @(#)start-diag	1.11 03/04/16
#
# Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#  @version 1.11 03/04/16 19:24:53
#
# 

##
# jdk OR jre
##
##JAVA_ED_ENV=jdk
JAVA_ED_ENV=jre2 
export JAVA_ED_ENV 

dirname=`/bin/dirname $0`
if [ -d $dirname ]; then
	## Set the I18N/L10N environment
	if [ -f $dirname/common.sh ]; then
		. $dirname/common.sh
	fi
else
	## this will be a simple echo
	/bin/gettext "Can not determine where start-diag is"
	echo ""
	exit 1
fi

basedir=`/usr/bin/pkgparam SUNWescom BASEDIR`
. ${basedir:=/opt}/SUNWsymon/sbin/es-common.sh

#
# Set the locale for I18N/L10N
# ----------------------------
set_inst_base_dir
check_for_l10n
TEXTDOMAIN="SUNW_HWDIAG"
export TEXTDOMAIN
setup_textdomain $TEXTDOMAIN

export BASE_PATH

thisArgs=$*

if [ $# -lt 1 ]; then
	if [ -x $BASE_PATH/lib/server/hd-server.sh ] ; then
		/usr/bin/nohup $BASE_PATH/lib/server/hd-server.sh > /dev/null 2>&1
		exit 0
	fi
	exit 1
fi

if [ $# -lt 3 ]; then
## for comp reason
	userInput="$1"
	if [ ${userInput} = "-server" ];  then
		if [ -x $BASE_PATH/lib/server/hd-server.sh ] ; then
			/usr/bin/nohup $BASE_PATH/lib/server/hd-server.sh > /dev/null 2>&1
			exit 0
		fi
		exit 1
	fi
	/bin/gettext "start-diag usage:"
	echo ""
	/bin/gettext "start-diag -server starts the Hardware Diagnostic Suite Server"
	echo ""
	exit 1
fi


if [  -x $BASE_PATH/lib/ui/hd-console.sh ] ; then
		$BASE_PATH/lib/ui/hd-console.sh $thisArgs
fi

