#!/bin/sh
#
# %W% %E%
#
# Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
# ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
#

#
# Startup script for the HTML Converter
#

PRG=$0
BINDIR=`dirname $0`
BINDIR=`cd $BINDIR; pwd`


# Test if HtmlConverter is a link
# SGI use -l

OS=`uname -s`

if [ "${OS}" = "Linux" ]
then
    LINKTEST="-L"
else
    LINKTEST="-h"
fi

if [ "${LINKTEST}" "${PRG}" ]
then
	{
	# Follow the link
	LINK=`ls -ld "${PRG}" | awk '{print $NF}'`
	# See if it is an absolute or relative path.
	CHAR=`expr "${LINK}" : '\(.\).*'`
	if [ "${CHAR}" = "/" ]
	then
		{
		BINDIR=`dirname "${LINK}"`
		BINDIR=`cd "${BINDIR}"; pwd`
		}
	else
		{
		BINDIR=`dirname "${BINDIR}/${LINK}"`
		BINDIR=`cd "${BINDIR}"; pwd`
		}
	fi
	}
fi

# Test path for jar file
if [ ! -f "${BINDIR}/../lib/htmlconverter.jar" ]
then
	exit 2
fi

# Execute the converter
${BINDIR}/java -jar ${BINDIR}/../lib/htmlconverter.jar $*
