#!/bin/sh
if [ "$HUDSON_HOME" = "" ]; then
  echo HUDSON_HOME is not set
  exit 1
fi


# search the installation directory

PRG=$0
progname=`basename $0`
saveddir=`pwd`

cd "`dirname $PRG`"

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
done

BINDIR=`dirname "$PRG"`/..

# make it fully qualified
cd "$saveddir"
BINDIR="`cd "$BINDIR" && pwd`"

exec java -jar "$BINDIR/lib/hudson-*.jar" "$@"
