#!/bin/sh
# Script to invoke XMLterm
# 1) as ./xmlterm from mozilla/dist/bin or the package directory, or
# 2) as xmlterm (invoking /usr/bin/xmlterm), if installed with RPM, or
# 3) as xmlterm, if dist/bin or package directory has been included in PATH

XMLTERM_CHROME="xmlterm.xul"
MOZILLA_BIN="./mozilla-bin"

# Determine command prefix
PREFIX=`dirname $0`

if [ "$PREFIX" = "." ]
then
   # Assume running in dist/bin or package directory (useful for testing)
   MOZILLA_DIR=`pwd`

else
   MOZILLA_DIR=""

   if [ -f /bin/rpm -a -f /usr/bin/xmlterm ]
   then
      # Try to find installation directory using RPM
      MOZILLA_DIR=`rpm -q --queryformat "%{INSTALLPREFIX}" xmlterm`
   fi

   if [ ! "$MOZILLA_DIR" ]
   then
      # Assume command prefix points to mozilla directory
      MOZILLA_DIR=$PREFIX
   fi
fi

echo cd $MOZILLA_DIR
cd $MOZILLA_DIR

if [ -f chrome/xmlterm/content/default/$XMLTERM_CHROME ]
then
    dummy=0
else
    echo "chrome://xmlterm/content/$XMLTERM_CHROME not found; error in installing XMLterm?"
    exit 1
fi

echo ./run-mozilla.sh $MOZILLA_BIN -chrome "chrome://xmlterm/content/$XMLTERM_CHROME"
./run-mozilla.sh $MOZILLA_BIN -chrome "chrome://xmlterm/content/$XMLTERM_CHROME"
