#!/bin/bash

#set -x

JAVAPATH="/opt/IBMJava/jre/bin/"
x=`type -p java 2>/dev/null`
if [ "$x" != "" ]
then
  JAVAPATH=`/usr/bin/dirname $x`
fi
##  This is a script to run the License Manager java app.
##  This script is invoked every time the HMC is started.
##  If the user accepts the terms of the license, the app will 
##  create a file in /opt/hsc/data.  This directory is checked
##  for the existence of that file each time the HMC is
##  started.  
##   

#   echo "run License Manager"
export PATH=/opt/ccfw/bin/framework:$JAVAPATH:$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
OP=`grep optype /etc/HmcInstall.cfg 2>/dev/null | cut -f2 -d "=" | sed -e 's/ //g'`
if [ "$OP" == "Upgrade" ]; then
   exit 0
fi

. /opt/hsc/data/hmccorrectlang

export CLASSPATH=${DEBUG_JARS_DIRECTORY}:${debug_jars}:${LANG_JAR}:/usr/websm/codebase/pluginjars/aca.jar:/usr/websm/codebase/pluginjars/hsc_bundles.jar:/usr/websm/codebase/pluginjars/hsc.jar:/opt/hsc/data:/opt/ccfw/ccfw.jar:$CLASSPATH

java -Xms20m -Xmx128m com.ibm.hsc.common.util.LicenseManager machine

java -Xms20m -Xmx128m com.ibm.hsc.common.util.LicenseManager hmc

# No longer needed here as the user license is shown on the 
# welcome page now
#/opt/hsc/bin/showUserLicense

exit 0
