sahara-image-elements/elements/oracle-java/install.d/33-java
Pino Toscano 2fb2422da8 Make almost all the element scripts as e/u/pipefail
Following the latest dib-lint reporting, make sure almost all the
scripts are enabling -e, -u, and pipefail.  This eases the discovery of
failing commands, and the usage of unset variables.

There are few exceptions with flags not set:

* elements/hadoop-hdp/install.d/40-install-hdp, set -e
  when installing HDP 2.0, it tries to install tez, which does not seem
  to exist in Hortonworks' repositories

* elements/ssh/install.d/33-ssh, set -e
  the version of augtool (part of augeas 0.10) in older Ubuntu versions
  (like Precise, needed by the cloudera plugin) exits with wrong return
  values in autosave mode

* elements/storm/install.d/60-storm, set -e
  It tries to change the permission of /etc/supervisord.conf, which does
  not seem to exist

Change-Id: Ic1314639dfc6a66c48ca87b6820707a2b0cb1dbd
Partial-Bug: #1435306
2015-04-07 12:46:39 +02:00

43 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
echo "Begin: installation of Java"
# NOTE: $(dirname $0) is read-only, use space under $TARGET_ROOT
JAVA_LOCATION=${JAVA_TARGET_LOCATION:-"/usr/java"}
JAVA_NAME="oracle-jdk"
JAVA_HOME=$JAVA_LOCATION/$JAVA_NAME
JAVA_DOWNLOAD_URL=${JAVA_DOWNLOAD_URL:-"http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.tar.gz"}
mkdir -p $JAVA_LOCATION
if [ -n "$JAVA_DOWNLOAD_URL" ]; then
install-packages wget
JAVA_FILE=$(basename $JAVA_DOWNLOAD_URL)
wget --no-check-certificate --no-cookies -c \
--header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \
-O $JAVA_LOCATION/$JAVA_FILE $JAVA_DOWNLOAD_URL
elif [ -n "$JAVA_FILE" ]; then
install -D -g root -o root -m 0755 $(dirname $0)/$JAVA_FILE $JAVA_LOCATION
fi
cd $JAVA_LOCATION
echo "Decompressing Java archive"
echo -e "\n" | tar -zxf $JAVA_FILE
echo "Setting up $JAVA_NAME"
chown -R root:root $JAVA_LOCATION
JAVA_DIR=`ls -1 $JAVA_LOCATION | grep -v tar.gz`
ln -s $JAVA_LOCATION/$JAVA_DIR $JAVA_HOME
setup-java-home $JAVA_HOME $JAVA_HOME
rm $JAVA_FILE
echo "End: installation of Java"