#!/bin/bash
ACUXE_BIN_INSTALLATION_DIR=/opt/compaq/cpqacuxe/bld/
export ACUXE_BIN_INSTALLATION_DIR
LD_LIBRARY_PATH=$ACUXE_BIN_INSTALLATION_DIR
export LD_LIBRARY_PATH
IM_CFGFILE_PATH=$ACUXE_BIN_INSTALLATION_DIR
export IM_CFGFILE_PATH
ACUXE_LOCK_FILES_DIR=/opt/compaq/cpqacuxe/bld/locks/
export ACUXE_LOCK_FILES_DIR


#
# need to see if this is a SLES 10 box
SUSEREL="/etc/SuSE-release"
VER=""
if [ -f "$SUSEREL" ]
then
        VER=`grep VERSION $SUSEREL | cut -d' ' -f3 | grep "^10"`
fi

#
# need to see if this is a RHEL5 box
RHREL="/etc/redhat-release"
if [ -z "$VER" ] && [ -f "$RHREL" ]
then
        VER=`grep Tikanga $RHREL`
fi

#
# need to see if this is a Debian Etch (2.6) box
DEBREL="/etc/debian_version"
if [ -z "$VER" ] && [ -f "$DEBREL" ]
then
        VER=`grep 4.0 $DEBREL`
fi

#
# need to see if this is a Debian Sarge 64bit 2.6 box
DEBREL="/etc/lsb-release"
if [ -z "$VER" ] && [ -f "$DEBREL" ]
then
        VER=`grep sarge $DEBREL`
fi

# Don't set LD_ASSUME_KERNEL on SLES 10, RHEL5, or Debian 2.6
if [ "$VER" == "" ]
then
        export LD_ASSUME_KERNEL=2.4.1
fi

# Don't set LD_ASSUME_KERNEL on SLES 10, RHEL5, or Debian 2.6
if [ "$VER" == "" ]
then
        export LD_ASSUME_KERNEL=2.4.1
fi


ACUXE_PASS_FAILED=0
if [ "$1" == "" ] || [ "$1" == "-R" ] || [ "$1" == "-d" ]; then
PROCESSES=`ps -e|grep hpsmhd`
if [ "$PROCESSES" = "" ]; then
   ACUXE_PASS_FAILED=1
fi
fi

if [ "$ACUXE_PASS_FAILED" = 0 ]; then
   chmod ug+s /opt/compaq/cpqacuxe/bld/ipcelmclient 2>/dev/null
   if [ '/usr/bin/tty -s' -o "$HPLSPINSTALL" = "TRUE" ]; then
      $ACUXE_BIN_INSTALLATION_DIR.acuxebin $*
      if [ "$1" == "-stop" ]
      then
         /etc/init.d/hpsmhd restart>/dev/null 2>&1
      fi

   else
      /usr/bin/X11/xterm -T xterm -hold -e $ACUXE_BIN_INSTALLATION_DIR.acuxebin $* 
      if [ "$?" != 0 ]; then
         $ACUXE_BIN_INSTALLATION_DIR.acuxebin $* 2>/dev/null|cat > /dev/null
      fi
   fi
else
   echo Can not run because of HP System Management Homepage is not started or uninstalled.
   echo Please try to use "/etc/init.d/hpsmhd start" to start it.
   exit 1
fi
