bisq/scripts/install_java.sh
Devin Bileck 85de38a063
Consolidate install_java.sh scripts
Rather than having a separate install_java.sh script for distributions
that use a different package manger, I updated install_java.sh to
handle package managers used by various Linux distributions.
2018-12-04 14:50:37 -08:00

33 lines
1,012 B
Bash

#!/usr/bin/env bash
JAVA_HOME=/usr/lib/jvm/openjdk-10.0.2
JDK_FILENAME=openjdk-10.0.2_linux-x64_bin.tar.gz
JDK_URL=https://download.java.net/java/GA/jdk10/10.0.2/19aef61b38124481863b1413dce1855f/13/openjdk-10.0.2_linux-x64_bin.tar.gz
# Determine which package manager to use depending on the distribution
declare -A osInfo;
osInfo[/etc/redhat-release]=yum
osInfo[/etc/arch-release]=pacman
osInfo[/etc/gentoo-release]=emerge
osInfo[/etc/SuSE-release]=zypp
osInfo[/etc/debian_version]=apt-get
for f in ${!osInfo[@]}
do
if [[ -f $f ]]; then
PACKAGE_MANAGER=${osInfo[$f]}
break
fi
done
if [ ! -d "$JAVA_HOME" ]; then
# Ensure curl is installed since it may not be
$PACKAGE_MANAGER -y install curl
curl -L -O $JDK_URL
mkdir -p $JAVA_HOME
tar -zxf $JDK_FILENAME -C $JAVA_HOME --strip 1
rm $JDK_FILENAME
update-alternatives --install /usr/bin/java java $JAVA_HOME/bin/java 2000
update-alternatives --install /usr/bin/javac javac $JAVA_HOME/bin/javac 2000
fi