#!/bin/ksh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# bos72L src/bos/diag/util/ecc_inv/ecc_mcode_get.sh 1.3 
#  
# Licensed Materials - Property of IBM 
#  
# Restricted Materials of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2010,2018 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 
# @(#)66	1.3  src/bos/diag/util/ecc_inv/ecc_mcode_get.sh, diagsup, bos72L, l2018_07A2 1/30/18 13:38:32
#
# ecc_mcode_get
#
# this program is a wrapper for a java executable
# used to retrieve files from the ecc database.
# It also create catalog.mic files from sdd's
# and can read from the command line or files.  
#
##############################################################
# Check to see if diagnostics can be run on this platform
##############################################################

/usr/sbin/bootinfo -M >/dev/null 2>&1
if [ "$?" -ne 101 -a "$?" -ne 103 ]
then
    /usr/bin/dspmsg -s 4 diagcd.cat 1 \
        "\n\nThe '$0' command is not supported on this system.\n\n"
    exit 0
fi

#Possible paths to the java executable
JAVAPATH6=/usr/java6/bin
JAVAPATH6_64=/usr/java6_64/bin
JAVAPATH7=/usr/java7/bin
JAVAPATH7_64=/usr/java7_64/bin

#Use the first one that's available.
if [ -d ${JAVAPATH6} ]
then
  JAVAPATH=${JAVAPATH6}
elif [ -d ${JAVAPATH6_64} ]
then
  JAVAPATH=${JAVAPATH6_64}
elif [ -d ${JAVAPATH7} ]
then
  JAVAPATH=${JAVAPATH7}
elif [ -d ${JAVAPATH7_64} ]
then
  JAVAPATH=${JAVAPATH7_64}
else
  JAVAPATH=
fi

#Our return code.  Default it to success.  
RC=0

#Double check to make sure we have Java installed.  We should because pre/co reqs but checked just in case.  
if [ -d ${JAVAPATH} ]
then
  #Set the path the java executable
  JAVA=${JAVAPATH}/java
  #Call java with -jar and execute our java program with all the inputs.  
  ${JAVA} -jar /usr/lpp/diagnostics/bin/ecc_inv.jar $*;
  #Return what the java executable gave us back
  RC=$?
else
  #We don't have the java path, fail gracefully
  /bin/echo "This program requires at least JAVA 6"
  RC=1
fi
#Exit with our return code
exit ${RC}
