#!/bin/bash

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

##  This is a script to run the X Manager java app.
##  This script is invoked every time the HMC is started.
##  
##  When the pHMC boots and begins the X windows display manager
##  startup (during run level 5 init), there is the possibilty that a
##  duplicate hostname and IP address already exist on the network.
##  The X server then prevents any connections and NOTHING gets 
##  displayed on the (ICEWM) desktop, aka "Blue Screen of Death".
##
##
##  The default xdm-config processing has altered to test for a
##  "bad" network connection. See /etc/X11/xdm/Xsetup_1.  If the
##  persistant flag indicating a network problem exists, run the
##  Java app to display the error message. The Xsetup_1 script
##  should have made the X server at least usable now and the HMC
##  can be launched.
##

if [ -f /var/hsc/log/ip_err_flag ]; then

   # Ok, let's do it - setup and launch the error message panel
   export PATH=$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

   export CLASSPATH=${DEBUG_JARS_DIRECTORY}:${debug_jars}:/usr/websm/codebase/pluginjars/aca.jar:/usr/websm/codebase/pluginjars/hsc.jar:/usr/websm/codebase/pluginjars/hsc_bundles.jar:/opt/hsc/data:/usr/websm/codebase/wsm.jar:$CLASSPATH
   java -Xms20m -Xmx128m com.ibm.hsc.common.util.XManager

#  clear persistant flag
   rm -f /var/hsc/log/ip_err_flag
fi
exit 0
