#!/bin/bash -P

# $Id: javaws,v 1.2 2003/07/14 15:30:42 jk Exp $

# @(#)javaws	1.8 02/12/11
#Script to start Java Web Start. Directory that this script is in is added to the
#LD_LIBRARY_PATH. JAVAWS_HOME is also set to the directory this script is in,
#unless it is already set.

SVPATH="${PATH}"
PATH=/usr/bin:/bin
PRG=`type -path $0`

while [ -h "${PRG}" ]; do
    ls=`ls -ld "${PRG}"`
    link=`expr "${ls}" : '.*-> \(.*\)$'`
    if expr "${link}" : '/' > /dev/null; then
       prg="${link}"
    else
       prg="`dirname ${PRG}`/${link}"
    fi
    PRG=`type -path "${prg}"`
done

DIRNAME=`dirname "${PRG}"`
APPHOME=`cd ${DIRNAME}; pwd`

if [ "${APPHOME##/}" = "${APPHOME}" ]; then
  # Doesn't start with a /, must be relative
  APPHOME=`pwd`/${APPHOME}
fi

# update LD_LIBRARY_PATH to include the directory containing this file
if [ -z "${LD_LIBRARY_PATH}" ]; then
  LD_LIBRARY_PATH=${APPHOME}
else
  LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${APPHOME}
fi

export LD_LIBRARY_PATH

# Update JAVAWS_HOME to be the directory the script is running from.
if [ -z "${JAVAWS_HOME}" ]; then
  JAVAWS_HOME=${APPHOME}
  export JAVAWS_HOME
fi

PATH="${SVPATH}"

exec ${APPHOME}/javawsbin "$@"

