1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#!/bin/bash
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This installs either OpenJDK or, if on Power hardware, IBM PPC Java.
# If successful, its only output should be two lines, the JAVA_HOME
# path, and the Java version, respectively.
set -e # exit immediately if any step fails
java_version() {
$JAVA_HOME/bin/java -version 2>&1 | head -n1 | awk -F\" '{print $2}'
}
find_java() {
if [[ -z "$JAVA_HOME" ]]; then
export JAVA_HOME=$(find $1 -name $2 | head -n1)
fi
}
if [[ -n "$JAVA_HOME" ]]; then
echo $JAVA_HOME
java_version
exit 0
fi
if [[ "$(uname -p)" == ppc64* ]]; then
find_java "/opt" "java-ppc64le-*"
if [[ -z "$JAVA_HOME" ]]; then
url='http://bazaar.launchpad.net/~bigdata-dev/bigdata-data/trunk/download/kevin.monroe%40canonical.com-20150112181544-3hnn2vrlp5n367kr/ibmjavappc64lesdk7.1-20150112181532-hmlx3rc0msz1feru-5/ibm-java-ppc64le-sdk-7.1-2.0.bin'
checksum='644c49b1ba7b400be84949d1ab556f379590c723ff5107dbe0c7fab9d259ab31'
filename='/tmp/ibm-installer.bin'
wget "$url" -O $filename -nv
if [[ "$(sha256sum $filename)" != "$checksum $filename" ]]; then
echo "Java installer download failed checksum" 1>&2
exit 1
fi
chmod a+x $filename
$filename -i silent > /dev/null
find_java "/opt" "java-ppc64le-*"
fi
else
version=7
find_java "/usr" "java-$version-openjdk-*"
if [[ -z "$JAVA_HOME" ]]; then
apt-get -qqy install openjdk-$version-jdk > /dev/null
find_java "/usr" "java-$version-openjdk-*"
fi
fi
if [[ -z "$JAVA_HOME" ]]; then
echo "Unable to find Java" 1>&2
exit 1
fi
echo $JAVA_HOME
java_version
|