Merge "Better setup for custom Java installation"
This commit is contained in:
commit
44ad7d1c62
@ -3,6 +3,8 @@
|
||||
echo "Begin: installation of Java"
|
||||
set -e
|
||||
|
||||
distro=$(lsb_release -is || :)
|
||||
|
||||
# NOTE: $(dirname $0) is read-only, use space under $TARGET_ROOT
|
||||
JAVA_HOME=$TARGET_ROOT/usr/java
|
||||
mkdir -p $JAVA_HOME
|
||||
@ -28,7 +30,34 @@ if [ -z "$JAVA_FILE" ]; then
|
||||
else
|
||||
cd $JAVA_HOME
|
||||
if [[ $JAVA_FILE == *.tar.gz ]]; then
|
||||
echo -e "\n" | tar -zxvf $JAVA_FILE
|
||||
echo "Decompressing Java archive"
|
||||
echo -e "\n" | tar -zxf $JAVA_FILE
|
||||
JAVA_NAME=`ls -1 /usr/java/ | grep -v tar.gz`
|
||||
echo "Setting up $JAVA_NAME"
|
||||
chown -R root:root $JAVA_HOME
|
||||
cat >> /etc/profile.d/java.sh <<EOF
|
||||
# Custom Java install
|
||||
export JAVA_HOME=/usr/java/$JAVA_NAME
|
||||
export PATH=\$PATH:/usr/java/$JAVA_NAME/bin
|
||||
EOF
|
||||
case "$distro" in
|
||||
Ubuntu )
|
||||
echo "Setting up alternatives for Java"
|
||||
update-alternatives --install "/usr/bin/java" "java" "/usr/java/$JAVA_NAME/bin/java" 1
|
||||
update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/$JAVA_NAME/bin/javac" 1
|
||||
update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/java/$JAVA_NAME/bin/javaws" 1
|
||||
|
||||
update-alternatives --set java /usr/java/$JAVA_NAME/bin/java
|
||||
update-alternatives --set javac /usr/java/$JAVA_NAME/bin/javac
|
||||
update-alternatives --set javaws /usr/java/$JAVA_NAME/bin/javaws
|
||||
;;
|
||||
Fedora | RedHatEnterpriseServer | CentOS )
|
||||
alternatives --install /usr/bin/java java /usr/java/$JAVA_NAME/bin/java 200000
|
||||
alternatives --install /usr/bin/javaws javaws /usr/java/$JAVA_NAME/bin/javaws 200000
|
||||
alternatives --install /usr/bin/javac javac /usr/java/$JAVA_NAME/bin/javac 200000
|
||||
alternatives --install /usr/bin/jar jar /usr/java/$JAVA_NAME/bin/jar 200000
|
||||
;;
|
||||
esac
|
||||
elif [[ $JAVA_FILE == *.bin ]]; then
|
||||
echo -e "\n" | sh $JAVA_FILE
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user