#!/bin/ksh
#set -x
trap "exit 0" 9 15
COMMAND_PATH="com.ibm.hsc.command.CmdLineRouter"
COMMAND_NAME="rmvterm"
JAVA="PATH=/opt/IBMJava/jre/bin:/usr/bin/:/bin:/opt/hsc/bin/:$PATH java ${JPDA_DEBUG}"


JAVAPATH="/opt/IBMJava/jre/bin/"
export LD_LIBRARY_PATH=/opt/hsc/lib/:/usr/lib/:$LD_LIBRARY_PATH
if [ "${DEBUG_JARS_DIRECTORY}" != "" ] ; then
  if [ -d ${DEBUG_JARS_DIRECTORY} ] ; then
    for i in ${DEBUG_JARS_DIRECTORY}/*.jar
    do
       debug_jars=${debug_jars}:$i
    done
  fi
fi

if [ "$LANG" = "C" ]
then
   lang="en"
else
   lang=`echo $LANG | cut -d'_' -f 1`
fi

if [ -f /opt/hsc/data/hmccorrectlang ]
then
. /opt/hsc/data/hmccorrectlang
fi

CLASSPATH=${DEBUG_HMC_CMD}:${LANG_JAR}:/usr/websm/codebase/pluginjars/ccfw.jar:/usr/websm/codebase/pluginjars/auifw.jar:/usr/websm/codebase/pluginjars/aca.jar:/usr/sbin/rsct/codebase/rmcapi.jar:/usr/websm/codebase/pluginjars/sniacimom.jar:/usr/websm/codebase/pluginjars/xerces.jar:/usr/websm/codebase/wsm.jar:/opt/hsc/jars/i18n/hsc_$lang.jar:/usr/websm/codebase/pluginjars/hsc_bundles.jar:/usr/websm/codebase/pluginjars/hsc.jar:/usr/websm/codebase/pluginjars/ccfw.jar:/usr/websm/codebase/pluginjars/ccfw_sslite.jar:$CLASSPATH
export CLASSPATH
PATH=$JAVAPATH:/opt/hsc/bin:$PATH
export PATH
echo $* | grep "help" 2>&1 1>/dev/null
if [ $? -eq 0 -o $# -eq 0 ]
then
  java -Djavax.net.ssl.keyStore=/usr/websm/codebase/SM.pubkr -Djavax.net.ssl.keyStorePassword=defp -Dorg.snia.wbem.cimom.properties=/opt/hsc/data/cim.properties -DHMCRealUser.name=$HMC_ORIGINAL_USER  $CLASS_PATH  $COMMAND_PATH $COMMAND_NAME $*
  exit $?
else
  vts=`java -Djavax.net.ssl.keyStore=/usr/websm/codebase/SM.pubkr -Djavax.net.ssl.keyStorePassword=defp -Dorg.snia.wbem.cimom.properties=/opt/hsc/data/cim.properties -DHMCRealUser.name=$HMC_ORIGINAL_USER $CLASS_PATH  $COMMAND_PATH $COMMAND_NAME "$1" "$2" "$3" "$4"`
fi
if [ $? -eq 0 ]
then
  if [ "$vts" != "null" ]
  then
    nvts=`echo ${vts##_VT_}`
    #echo "NVTS "$nvts
    echo Sending Force close..
    s=`echo ${nvts%%_VT_}`
    /opt/hsc/bin/vxterm $s 2>/dev/null
  fi
else
  echo $vts
fi
/bin/stty sane
exit $?
