#!/bin/bash

#---------------------------------------------------------
#
# This is the script is invoked by IBM.ServiceRMd.
#
#   lshsc:       to collect Paritition Map for each SE.
#   HSCVPD:      to get HSC MTMS.
#
# These utils are being called this way to in case a
# Java class get exception and the JNI layer might cause
# ServiceRM to hang.
#
#---------------------------------------------------------
#
# echo $1 $2 $3 $4
#
#---------------------------------------------------------
# Use the following for debug - output will be sent to
# /var/ct/IBM.ServiceRM.stderr
# set -x

#---------------------------------------------------------

if [ "$1" == "lshsc" ]
then
   echo "calling /opt/hsc/bin/lshsc -c$2 -w -f$3"
   /opt/hsc/bin/lshsc -c$2 -w -f$3
fi

#---------------------------------------------------------

if [ "$1" == "HSCVPD" ]
then
   echo "calling HSCVPD"
   
   . /etc/profile.d/hsc.sh

   x=`type -p java 2>/dev/null`
   if [ "$x" != "" ]
   then
     JAVAPATH=`/usr/bin/dirname $x`
   fi
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

   export CLASSPATH=${DEBUG_JARS_DIRECTORY}:${debug_jars}:.:/usr/websm/codebase/pluginjars/aca.jar:/usr/websm/codebase/pluginjars/sniacimom.jar:/usr/websm/codebase/pluginjars/xerces.jar:/usr/websm/codebase/pluginjars/ccfw.jar:/usr/websm/codebase/pluginjars/auifw.jar:/usr/websm/codebase/pluginjars/hsc.jar:/usr/websm/codebase/pluginjars/hsc_bundles.jar:$CLASSPATH

   $JAVAPATH/java -Djavax.net.ssl.keyStore=/opt/ccfw/data/SM.pubkr -Djavax.net.ssl.keyStorePassword=defp -Dorg.snia.wbem.cimom.properties=/opt/hsc/data/cim.properties com.ibm.hsc.common.util.HSCVPD > /var/hsc/sfp/hscinfo
fi 




