#!/bin/bash
# This is the script to install the IBM JRE
#

. /etc/autobench.conf || . functions

. $AUTODIR/var/server-repository

# Figure out the architecture
ARCH=`uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ \
      -e s/sa110/arm/`  # Standard

pushd $AUTODIR/sources > /dev/null

# Try and fetch the package
wget -q "$SERVER_REPO/sources/IBMJava2-latest-$ARCH.tgz"
if [ $? -ne 0 ]; then
  echo "Unable to find a JRE for this distribution from the repository."
  echo "Please get the appropriate version.  Try this url:"
  echo "https://www6.software.ibm.com/dl/lxdk/lxdk-p"
  exit 1
fi

# Install it
rm -rf IBMJava2 2> /dev/null
DST_DIR=`tar ztf IBMJava2-latest-$ARCH.tgz | head -n 1`
tar zxf IBMJava2-latest-$ARCH.tgz
ln -sf $DST_DIR IBMJava2

popd > /dev/null
