#! /usr/bin/sh

CUR_DIR=`pwd`
USERNAME=`whoami`

#Verify that current user is root.
if [ "${USERNAME}" != "root" ]
then
{
  echo "You do not have the privilege necessary to execute this function"
  echo "Please login as root and restart "
  exit 1
}
fi

#Verify  that the JAVA_HOME environment variable is set. 
if [ "${JAVA_HOME}" = "" ]
then
{
	echo "Please set the JAVA_HOME variable to the base directory of your java installation"
  	exit 1
}
fi

#Verify  that the JAVA_HOME environment variable is set to the right directory.
if [ -f $JAVA_HOME/bin/java ]
then
{
	export JAVA_HOME
	PATH=$PATH:$JAVA_HOME/bin
	CLASSPATH=$JAVA_HOME/lib/classes.zip:.:$CUR_DIR/install.jar
    export PATH
	export CLASSPATH
}
else
{
	echo "The JAVA_HOME variable does not refer to the right directory !"
	exit 1
}
fi

#Perform the actual install
java -classpath $CLASSPATH com.baan.bfe.install.setup $*

