From c7790851003d05887a017853c8b4fee9a7887191 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Tue, 8 May 2018 08:01:28 -0700 Subject: [PATCH] New script, install_java! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit And what do you think install_java does? If you just say it's going to install the latest version of perl, I'm going to hit you. On Raspbian systems it defaults to oracle-java8-jdk because that's what Raspbian defaults too _for now_. Apparently openjdk 9 can keep up with it and possibly run circles around it, in which case maybe we want to use default-jre everywhere. I'm for not using Oracle Java regardless because … Oracle, but if it's not just as fast, those of you running armv6-based Pis are going to not be happy if we drop it. --- scripts/install_java | 70 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100755 scripts/install_java diff --git a/scripts/install_java b/scripts/install_java new file mode 100755 index 0000000..76858e0 --- /dev/null +++ b/scripts/install_java @@ -0,0 +1,70 @@ +#! /bin/bash +# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh: + +# install_java - make sure we have java installed +# +# To the extent possible under law, T. Joseph Carter and Ivan Drucker have +# waived all copyright and related or neighboring rights to the a2cloud +# scripts themselves. Software used or installed by these scripts is subject +# to other licenses. This work is published from the United States. + +# Find the path of our source directory +a2cSource="$( dirname "${BASH_SOURCE[0]}" )/.." +pushd $a2cSource >/dev/null +a2cSource="$PWD" +popd >/dev/null +if [[ ! -f "$a2cSource/.a2cloud_source" ]]; then + printf "\na2cloud: cannot find a2cloud source directory in $a2cSource.\n\n" + exit 1 +fi + +# Make sure ras2_{os,arch} get set +. "$a2cSource/scripts/system_ident" -q + +check_freespace() { + # we use df -k because its output works on Linux and BSD/Mac + freeSpace=$(df -k / | tail -1 | awk '{ print $4 }') + (( $freeSpace > 360000 )) + return $? +} + +install_java() { + sudo apt-get update + if [[ $ras2_os == rpi-* ]]; then + sudo apt-get -y install oracle-java8-jdk + else + # Used to go out and find Oracle Java, but we don't need it. + sudo apt-get -y install default-jre + fi + sudo apt-get clean +} + +if ! hash java 2>/dev/null; then + printf "\nJava is not installed" + if check_freespace; then + printf ", but we can install it.\n" + + install_java + else + cat <<-EOF + amd this script cannot continue. + + You don't seem to have enough free space to install Java, which is + needed by several components we install (ADTPro and AppleCommander, + for example.) On a Raspberry Pi, it is possible that you may simply + need to expand your filesystem to fill the SD card. You can do that + by running "sudo raspi-config" and selecting the appropriate option. + + If that's not the cause, you might investigate to see if you happen + to have unwanted large packages installed. Some systems come loaded + with full desktop environments, development IDEs, or other large + packages or package groups you don't need. + + Failing all of that, you can figure out how to get java installed and + into your default path and set JAVA_HOME. If we find java in your + path this script will assume that we should simply use that. We do + recommend Java 8 or above. + EOF + exit 1 + fi +fi