#!/bin/bash
##################################################################
### copyright 2002 Compaq Information Technologies Group, L.P. ###
##################################################################

lsmod | grep cpqasm >/dev/null 2>&1
if [ $? -eq 1 ]; then
   echo "ERROR: $0 requires the module cpqasm to be loaded"
   exit 1
fi


if [ "$DISPLAY" = "" ]; then
   if [ -f /sbin/hpimlview ]; then
      /sbin/hpimlview
   fi
else

ls /usr/lib > /tmp/lslib
TCLHERE=`awk '/tcl[xX]/{++x} BEGIN {x=0} END {print x}' /tmp/lslib`
rm -rf /tmp/lslib
if [ $TCLHERE != "0" ]; then

	OSVER=`awk '/Red Hat Linux release 7.2/{++x} BEGIN {x=0} END {print x}' /etc/issue`
	if [ ${#OSVER} == 1 ]; then
		if [ ! -f /usr/lib/libtclx8.3.so ]; then
			if [ -f /usr/lib/libtclx.so ]; then
				cp /usr/lib/libtclx.so /usr/lib/libtclx8.3.so
			fi
		fi
	fi 
	
	if [ -e /usr/bin/tixwish ]; then
		TIXWISH=/usr/bin/tixwish
	elif [ -e /usr/bin/tixwish4.1.8.0 ]; then
		TIXWISH=/usr/bin/tixwish4.1.8.0
	elif [ -e /usr/bin/tixwish4.1.8.3 ]; then
		TIXWISH=/usr/bin/tixwish4.1.8.3
	else
  		echo "ERROR: tixwish not installed."
  		echo "X-Windows must be installed to use the IML viewer."
  		exit 1
	fi

	$TIXWISH /sbin/cpqimlview.tcl

else
	echo "ERROR: tclX not installed."
	echo "tclX must be installed to use the IML viewer."
	exit 1
fi
fi

exit 0
