Browse Source

Simplification of hadoop_fedora/11-setup-java implementation

Change-Id: If6a9f6a577fd5cf8426aa86a0155610d7e96dde5
tags/0.2a2^0
Matthew Farrellee 5 years ago
parent
commit
4cd9ca4df8

+ 23
- 33
elements/hadoop_fedora/post-install.d/11-setup-java View File

@@ -1,44 +1,34 @@
1 1
 #!/bin/bash
2 2
 echo "Java setup begins"
3
-install-packages wget
4
-tmp_dir=/tmp/java/
5
-mkdir -p $TARGET_ROOT/$tmp_dir
6 3
 set -e
7
-if [ -z "$JAVA_DOWNLOAD_URL" ]; then
8
-   script_dir=$(dirname $0)
9
-   install -D -g root -o root -m 0755 $script_dir/$JAVA_FILE $TARGET_ROOT/$tmp_dir
10
-   filename=$JAVA_FILE
11
-   echo "Java file moved"
12
-else
13
-   wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" -P $TARGET_ROOT/$tmp_dir $JAVA_DOWNLOAD_URL
4
+
5
+# NOTE: $(dirname $0) is read-only, use space under $TARGET_ROOT
6
+JAVA_HOME=$TARGET_ROOT/usr/java
7
+mkdir -p $JAVA_HOME
8
+
9
+if [ -n "$JAVA_DOWNLOAD_URL" ]; then
10
+   install-packages wget
11
+   wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" -P $JAVA_HOME $JAVA_DOWNLOAD_URL
14 12
    if [ $? -eq 0 ]; then
15
-      echo "Java is downloading"
16
-      else
17
-      echo "Url error. Exit"
13
+      echo "Java downloaded"
14
+   else
15
+      echo "Error downloading java. Exiting."
18 16
       exit 1
19 17
    fi
20
-   filename=$(find $TARGET_ROOT/$tmp_dir -maxdepth 1 -name "jdk*")
21
-   filename=$(basename $filename)
18
+   JAVA_FILE=$(basename $JAVA_DOWNLOAD_URL)
19
+elif [ -n "$JAVA_FILE" ]; then
20
+   install -D -g root -o root -m 0755 $(dirname $0)/$JAVA_FILE $JAVA_HOME
22 21
 fi
23 22
 
24
-if echo $tmp_dir/$filename | grep -q -s -F .tar.gz ; then
25
-   pushd $TARGET_ROOT/$tmp_dir
26
-   echo -e "\n" | tar -zxvf $TARGET_ROOT/$tmp_dir/$filename
27
-   popd
28
-   else
29
-      if echo $filename | grep -q -s -F .bin ; then
30
-         pushd $TARGET_ROOT/$tmp_dir
31
-         echo -e "\n" | sh $filename
32
-         rm $filename
33
-         popd
34
-      fi
23
+cd $JAVA_HOME
24
+if echo $JAVA_FILE | grep -q -s -F .tar.gz ; then
25
+   echo -e "\n" | tar -zxvf $JAVA_FILE
26
+elif echo $JAVA_FILE | grep -q -s -F .bin ; then
27
+   echo -e "\n" | sh $JAVA_FILE
28
+else
29
+   echo "Unknown file type: $JAVA_FILE. Exiting."
30
+   exit 1
35 31
 fi
32
+rm $JAVA_FILE
36 33
 
37
-filename=$(find $TARGET_ROOT/$tmp_dir -maxdepth 1 -type d -name "jdk*")
38
-filename=$(basename $filename)
39
-javaPath=/usr/java/
40
-mkdir -p $TARGET_ROOT/$javaPath
41
-mv $TARGET_ROOT/$tmp_dir/$filename $TARGET_ROOT/$javaPath
42
-rm -r $tmp_dir
43 34
 echo "Java was installed"
44
-

+ 1
- 1
elements/hadoop_fedora/post-install.d/12-setup-hadoop View File

@@ -2,7 +2,7 @@
2 2
 echo "Hadoop setup begins"
3 3
 tmp_dir=/tmp/hadoop
4 4
 
5
-install-packages openssh-server
5
+install-packages openssh-server wget
6 6
 echo "Creating hadoop user & group"
7 7
 adduser -G adm,wheel hadoop
8 8
 

Loading…
Cancel
Save