diff --git a/.travis.yml b/.travis.yml index cc4e4413a..aab3f47ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -134,8 +134,8 @@ jobs: script: # AdoptOpenJDK Java on 32bit ARMv7 on 32bit OS on Travis Arm64 HW - export HW=rpi2 - - sed -i 's/^java_opt=.*/java_opt=AdoptOpenJDK/' build-image/openhabian.conf + - sed -i 's/^java_opt=.*/java_opt=Adopt11/' build-image/openhabian.conf - docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-arm32hf-native . - - echo -e "\n\e[36mopenHABian test installation 64bit AdoptOpenJDK Java \e[31m on 32bit OS\e[36m on virtual $HW ...\n" + - echo -e "\n\e[36mopenHABian test installation 64bit AdoptOpenJDK 11 Java \e[31m on 32bit OS\e[36m on virtual $HW ...\n" - docker run --memory="1g" --memory-reservation="1g" --name "openhabian-${HW}" -d openhabian/${HW}-openhabian; - docker exec -i "openhabian-${HW}" bash -c './build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local' diff --git a/Dockerfile.openhabian-ARMv6hf-native b/Dockerfile.openhabian-ARMv6hf-native index be9f6d247..74338dc31 100644 --- a/Dockerfile.openhabian-ARMv6hf-native +++ b/Dockerfile.openhabian-ARMv6hf-native @@ -51,4 +51,3 @@ VOLUME ["/sys/fs/cgroup"] STOPSIGNAL 37 CMD ["bash", "start.sh"] - diff --git a/Dockerfile.openhabian-aarch64-64bit b/Dockerfile.openhabian-aarch64-64bit index 51809453b..cca3d424f 100644 --- a/Dockerfile.openhabian-aarch64-64bit +++ b/Dockerfile.openhabian-aarch64-64bit @@ -40,7 +40,7 @@ RUN cp docker-systemctl-replacement/files/docker/systemctl3.py /bin/systemctl ENTRYPOINT ["/usr/bin/entry.sh"] RUN adduser openhabian --gecos "Openhabian,,," --disabled-password -RUN echo "openhabian:openhabian" | chpasswd +RUN echo "openhabian:openhabian" | chpasswd RUN /bin/echo -n "Running on " && /usr/bin/arch COPY . /opt/openhabian/ diff --git a/Dockerfile.openhabian-aarch64-native b/Dockerfile.openhabian-aarch64-native index cceb4be3f..41808f571 100644 --- a/Dockerfile.openhabian-aarch64-native +++ b/Dockerfile.openhabian-aarch64-native @@ -40,7 +40,7 @@ RUN cp docker-systemctl-replacement/files/docker/systemctl3.py /bin/systemctl ENTRYPOINT ["/usr/bin/entry.sh"] RUN adduser openhabian --gecos "Openhabian,,," --disabled-password -RUN echo "openhabian:openhabian" | chpasswd +RUN echo "openhabian:openhabian" | chpasswd RUN /bin/echo -n "Running on " && /usr/bin/arch COPY . /opt/openhabian/ diff --git a/Dockerfile.openhabian-arm32hf-CM3 b/Dockerfile.openhabian-arm32hf-CM3 index d5696744d..e8d4e6640 100644 --- a/Dockerfile.openhabian-arm32hf-CM3 +++ b/Dockerfile.openhabian-arm32hf-CM3 @@ -39,7 +39,7 @@ RUN cp docker-systemctl-replacement/files/docker/systemctl3.py /bin/systemctl ENTRYPOINT ["/usr/bin/entry.sh"] RUN adduser openhabian --gecos "Openhabian,,," --disabled-password -RUN echo "openhabian:openhabian" | chpasswd +RUN echo "openhabian:openhabian" | chpasswd RUN /bin/echo -n "Running on " && /usr/bin/arch COPY . /opt/openhabian/ diff --git a/Dockerfile.openhabian-arm32hf-emulated b/Dockerfile.openhabian-arm32hf-emulated index bd0fdce86..b500a8377 100644 --- a/Dockerfile.openhabian-arm32hf-emulated +++ b/Dockerfile.openhabian-arm32hf-emulated @@ -1,6 +1,6 @@ # assumes at least ARMv71 but not ARMv8 (aarch64) yet FROM balenalib/raspberry-pi2-debian-node:latest-buster - + RUN [ "cross-build-start" ] ENV container docker @@ -39,7 +39,7 @@ RUN cp docker-systemctl-replacement/files/docker/systemctl3.py /bin/systemctl ENTRYPOINT ["/usr/bin/entry.sh"] RUN adduser openhabian --gecos "Openhabian,,," --disabled-password -RUN echo "openhabian:openhabian" | chpasswd +RUN echo "openhabian:openhabian" | chpasswd RUN /bin/echo -n "Running on " && /usr/bin/arch COPY . /opt/openhabian/ @@ -54,4 +54,3 @@ STOPSIGNAL 37 CMD ["bash", "start.sh"] RUN [ "cross-build-end" ] - diff --git a/Dockerfile.openhabian-x86 b/Dockerfile.openhabian-x86 index 19239bbc1..ed490ef3e 100644 --- a/Dockerfile.openhabian-x86 +++ b/Dockerfile.openhabian-x86 @@ -37,7 +37,7 @@ RUN cp docker-systemctl-replacement/files/docker/systemctl3.py /bin/systemctl ENTRYPOINT ["/usr/bin/entry.sh"] RUN adduser openhabian --gecos "Openhabian,,," --disabled-password -RUN echo "openhabian:openhabian" | chpasswd +RUN echo "openhabian:openhabian" | chpasswd RUN /bin/echo -n "Running on " && /usr/bin/arch COPY . /opt/openhabian/ diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 000000000..c0accce5b --- /dev/null +++ b/NEWS.md @@ -0,0 +1,8 @@ +### May 29, 2020 +New options for the JDK that runs openHAB are now available: + + - Java Zulu 8 32-Bit OpenJDK (default on arm based platforms) + - Java Zulu 8 64-Bit OpenJDK (default on x86 based platforms) + - Java Zulu 11 32-Bit OpenJDK (beta testing for openHAB 3) + - Java Zulu 11 64-Bit OpenJDK (beta testing for openHAB 3) + - AdoptOpenJDK 11 OpenJDK (beta replacement for Zulu) diff --git a/build-image/openhabian.conf b/build-image/openhabian.conf index f4cd03530..d0d1bb57c 100644 --- a/build-image/openhabian.conf +++ b/build-image/openhabian.conf @@ -52,7 +52,7 @@ mode=unattended #release=buster # Java architecture mode -# Valid arguments: "AdoptOpenJDK", "Zulu8-32", "Zulu8-64", "Zulu11-32", or "Zulu11-64" +# Valid arguments: "Adopt11", "Zulu8-32", "Zulu8-64", "Zulu11-32", or "Zulu11-64" java_opt=Zulu8-32 # vim: filetype=sh diff --git a/build-image/openhabian.pi-raspbian.conf b/build-image/openhabian.pi-raspbian.conf index 088607773..f064c5fdc 100644 --- a/build-image/openhabian.pi-raspbian.conf +++ b/build-image/openhabian.pi-raspbian.conf @@ -52,7 +52,7 @@ mode=unattended #release=buster # Java architecture mode -# Valid arguments: "AdoptOpenJDK", "Zulu8-32", "Zulu8-64", "Zulu11-32", or "Zulu11-64" +# Valid arguments: "Adopt11", "Zulu8-32", "Zulu8-64", "Zulu11-32", or "Zulu11-64" java_opt=Zulu8-32 # vim: filetype=sh diff --git a/build-image/openhabian.pine64-xenial.conf b/build-image/openhabian.pine64-xenial.conf index 5ff433ac4..6482648a8 100644 --- a/build-image/openhabian.pine64-xenial.conf +++ b/build-image/openhabian.pine64-xenial.conf @@ -26,5 +26,5 @@ wifi_country="" # vim: filetype=sh # Java architecture mode -# Valid arguments: "AdoptOpenJDK", "Zulu8-32", "Zulu8-64", "Zulu11-32", or "Zulu11-64" +# Valid arguments: "Adopt11", "Zulu8-32", "Zulu8-64", "Zulu11-32", or "Zulu11-64" java_opt=Zulu8-32 diff --git a/docs/openhabian.md b/docs/openhabian.md index ae7bbea81..5059049fc 100644 --- a/docs/openhabian.md +++ b/docs/openhabian.md @@ -159,7 +159,7 @@ In `openhabian.conf`, uncomment and complete the lines reading `hw=`, `hwarch=` {: #debug-mode} ### Debug mode -See [Troubleshooting] section if you run into trouble installing. If you want to turn on debug mode, +See [Troubleshooting] section if you run into trouble installing. If you want to turn on debug mode, edit `openhabian.conf` and set the `debug=` parameter to either `none`, `on` or `maximum`. {: #ipv6-notes} diff --git a/functions/config.bash b/functions/config.bash index 04edd2d2c..68f59ddca 100644 --- a/functions/config.bash +++ b/functions/config.bash @@ -31,7 +31,7 @@ clean_config_userpw() { } ## Update java architecture in config file -## Valid arguments: "AdoptOpenJDK", "Zulu8-32", "Zulu8-64", "Zulu11-32", or "Zulu11-64" +## Valid arguments: "Adopt11", "Zulu8-32", "Zulu8-64", "Zulu11-32", or "Zulu11-64" update_config_java() { if [ "$1" == "Zulu8-64" ] || [ "$1" == "Zulu11-64" ]; then if (! is_x86_64 && ! [ "$(getconf LONG_BIT)" == "64" ]) || (! is_aarch64 && ! [ "$(getconf LONG_BIT)" == "64" ]); then diff --git a/functions/influxdb+grafana.bash b/functions/influxdb+grafana.bash index 72b7ffdaa..fc686ab43 100644 --- a/functions/influxdb+grafana.bash +++ b/functions/influxdb+grafana.bash @@ -225,7 +225,8 @@ influxdb_grafana_setup() { influxdb_install() { local influxdb_address local influxdb_admin_username - local dist codename + local dist + local codename cond_echo "" echo "Installing InfluxDB..." @@ -242,7 +243,7 @@ influxdb_install() { influxdb_admin_username="admin" # if [ ! -f /etc/influxdb/influxdb.conf ]; then cond_redirect wget -O - https://repos.influxdata.com/influxdb.key | apt-key add - || FAILED=1 - echo "deb https://repos.influxdata.com/$dist $codename stable" > /etc/apt/sources.list.d/influxdb.list || FAILED=1 + echo "deb https://repos.influxdata.com/${dist} ${codename} stable" > /etc/apt/sources.list.d/influxdb.list || FAILED=1 cond_redirect apt-get update || FAILED=1 cond_redirect apt-get -y install influxdb || FAILED=1 @@ -301,7 +302,7 @@ grafana_install(){ echo -n "Wait for Grafana to start... " curl --retry 5 --retry-connrefused -s http://localhost:3000 >/dev/null || FAILED=2 if [ $FAILED -eq 2 ]; then echo -n "FAILED "; return 2; else echo -n "OK "; fi - sleep 10 + sleep 10 cond_echo "" # password reset required if Grafana password was already set before (no first-time install) diff --git a/functions/java-jre.bash b/functions/java-jre.bash index 1b036892c..ac21a04cf 100644 --- a/functions/java-jre.bash +++ b/functions/java-jre.bash @@ -1,46 +1,101 @@ #!/usr/bin/env bash # shellcheck disable=SC2181 # shellcheck disable=SC2144 +# shellcheck disable=SC2069 ## Install appropriate Java version based on current choice. -## Valid arguments: "AdoptOpenJDK", "Zulu8-32", "Zulu8-64", "Zulu11-32", or "Zulu11-64" +## Valid arguments: "Adopt11", "Zulu8-32", "Zulu8-64", "Zulu11-32", or "Zulu11-64" ## -## java_install_and_update(String type) +## java_install_or_update(String type) ## java_install_or_update(){ + local branch + + branch=$(git -C "/opt/openhabian" rev-parse --abbrev-ref HEAD) + # Make sure we don't overwrite existing unsupported installations - if ! [ -x "$(command -v java)" ] || [[ ! "$(java -version > /dev/null 2>&1)" == *"Zulu"* ]] || [[ ! "$(java -version > /dev/null 2>&1)" == *"AdoptOpenJDK"* ]]; then - if [ "$1" == "AdoptOpenJDK" ]; then - adoptopenjdk_install_apt - elif ! [ "$1" == "AdoptOpenJDK" ]; then - if [[ "$(java -version > /dev/null 2>&1)" == *"AdoptOpenJDK"* ]] && [ -d /opt/jdk/* ]; then - cond_redirect systemctl stop openhab2.service - cond_redirect java_alternatives_reset "Zulu" - cond_redirect systemctl start openhab2.service - else - if [ "$1" == "Zulu8-64" ]; then + if ! [ -x "$(command -v java)" ] || [[ ! "$(java -version 2>&1> /dev/null)" == *"Zulu"* ]] || [[ ! "$(java -version 2>&1> /dev/null)" == *"AdoptOpenJDK"* ]]; then + if [ "$1" == "Adopt11" ]; then + cond_redirect adoptopenjdk_install_apt + elif ! [ "$1" == "Adopt11" ]; then + if [[ "$(java -version 2>&1> /dev/null)" == *"AdoptOpenJDK"* ]] && [ -d /opt/jdk/* ]; then + cond_redirect java_zulu_install + fi + if [ "$1" == "Zulu8-64" ] || [ "$1" == "Zulu11-64" ]; then + if is_aarch64 || is_x86_64 && [ "$(getconf LONG_BIT)" == "64" ]; then if is_x86_64; then - java_zulu_enterprise_apt 8 + if [ "$1" == "Zulu8-64" ]; then + cond_redirect java_zulu_enterprise_apt 8 + elif [ "$1" == "Zulu11-64" ]; then + cond_redirect java_zulu_enterprise_apt 11 + fi else - if java_zulu_tar_update_available Zulu8-64; then - java_zulu_tar Zulu8-64 + if [ "$1" == "Zulu8-64" ]; then + if cond_redirect java_zulu_update_available Zulu8-64; then + echo -n "$(timestamp) [openHABian] Installing Java Zulu 8 64-Bit OpenJDK... " + if ! [ -x "$(command -v java)" ] && [ -d /opt/jdk/* ]; then + cond_redirect java_zulu_install + elif [ "$branch" == "stable" ]; then + java_zulu_stable Zulu8-64 + else + cond_redirect java_zulu_fetch Zulu8-64 + cond_redirect java_zulu_install + fi + fi + elif [ "$1" == "Zulu11-64" ]; then + if cond_redirect java_zulu_update_available Zulu11-64; then + echo -n "$(timestamp) [openHABian] Installing Java Zulu 11 64-Bit OpenJDK... " + if ! [ -x "$(command -v java)" ] && [ -d /opt/jdk/* ]; then + cond_redirect java_zulu_install + elif [ "$branch" == "stable" ]; then + java_zulu_stable Zulu11-64 + else + cond_redirect java_zulu_fetch Zulu11-64 + cond_redirect java_zulu_install + fi + fi fi fi - elif [ "$1" == "Zulu11-64" ]; then - if is_x86_64; then - java_zulu_enterprise_apt 11 + else + if [ -n "$INTERACTIVE" ]; then + whiptail --title "Incompatible hardware detected" --msgbox "Zulu OpenJDK 64-bit: this option does not currently work on your platform.\\n\\nDefaulting to Java Zulu 8 32-bit installation." 10 60 else - if java_zulu_tar_update_available Zulu11-64; then - java_zulu_tar Zulu11-64 + echo "Zulu OpenJDK 64-bit: this option does not currently work on your platform. Defaulting to Java Zulu 8 32-bit installation." + if cond_redirect java_zulu_update_available Zulu8-32; then + echo -n "$(timestamp) [openHABian] Installing Java Zulu 8 32-Bit OpenJDK... " + if ! [ -x "$(command -v java)" ] && [ -d /opt/jdk/* ]; then + cond_redirect java_zulu_install + elif [ "$branch" == "stable" ]; then + java_zulu_stable Zulu8-32 + else + cond_redirect java_zulu_fetch Zulu8-32 + cond_redirect java_zulu_install + fi fi fi - else # Default to 32-bit installation - if [ "$1" == "Zulu11-32" ]; then - if java_zulu_tar_update_available Zulu11-32; then - java_zulu_tar Zulu11-64 + fi + else # Default to 32-bit installation + if [ "$1" == "Zulu11-32" ]; then + if cond_redirect java_zulu_update_available Zulu11-32; then + echo -n "$(timestamp) [openHABian] Installing Java Zulu 11 32-Bit OpenJDK... " + if ! [ -x "$(command -v java)" ] && [ -d /opt/jdk/* ]; then + cond_redirect java_zulu_install + elif [ "$branch" == "stable" ]; then + java_zulu_stable Zulu11-32 + else + cond_redirect java_zulu_fetch Zulu11-32 + cond_redirect java_zulu_install fi - elif java_zulu_tar_update_available Zulu8-32; then - java_zulu_tar Zulu8-32 + fi + elif cond_redirect java_zulu_update_available Zulu8-32; then + echo -n "$(timestamp) [openHABian] Installing Java Zulu 8 32-Bit OpenJDK... " + if ! [ -x "$(command -v java)" ] && [ -d /opt/jdk/* ]; then + cond_redirect java_zulu_install + elif [ "$branch" == "stable" ]; then + java_zulu_stable Zulu8-32 + else + cond_redirect java_zulu_fetch Zulu8-32 + cond_redirect java_zulu_install fi fi fi @@ -49,145 +104,96 @@ java_install_or_update(){ cond_redirect java -version } -## Install Java Zulu directly from fetched .tar.gz file +## Use special handling when installing Zulu on the stable branch ## Valid arguments: "Zulu8-32", "Zulu8-64", "Zulu11-32", or "Zulu11-64" ## -## java_zulu_tar(String arch) +## java_zulu_stable(String arch) ## -java_zulu_tar(){ - local link - local jdkTempLocation - local jdkInstallLocation - local jdkLib - local jdkArch +java_zulu_stable(){ + local updateText + local consoleText - cond_redirect systemctl stop openhab2.service + updateText="Updating Java may result in issues as it has not recieved extensive testing to verify compatibility.\\n\\nIf you wish to continue and encounter any errors please let us know so we can look into them to improve future compatibility." + consoleText="[openHABian] WARNING: Untested Java Version, you may experience issues as this version of Java has not recieved extensive testing to verify compatibility." - if [ "$1" == "Zulu8-32" ] || [ "$1" == "Zulu11-32" ]; then - if [ "$1" == "Zulu8-32" ]; then - echo -n "$(timestamp) [openHABian] Installing Java Zulu 8 32-Bit OpenJDK... " - link=$(fetch_zulu_tar_url Zulu8-32) - elif [ "$1" == "Zulu11-32" ]; then - echo -n "$(timestamp) [openHABian] Installing Java Zulu 11 32-Bit OpenJDK... " - link=$(fetch_zulu_tar_url Zulu11-32) - fi - if is_arm; then - jdkArch="aarch32" - else - jdkArch="i386" - fi + if [ -n "$INTERACTIVE" ]; then + if ! (whiptail --defaultno --title "Untested Version of Java" --no-button "Back" --yes-button "Continue" --yesno "$updateText" 11 80); then echo "CANCELED"; return 0; fi + cond_redirect java_zulu_fetch "$1" + cond_redirect java_zulu_install + else + echo "$(timestamp) $consoleText" + cond_redirect java_zulu_fetch "$1" + cond_redirect java_zulu_install + fi +} - if is_aarch64; then - dpkg --add-architecture armhf - cond_redirect apt-get --yes install libc6:armhf libncurses5:armhf libstdc++6:armhf - fi +## Install Java Zulu directly from fetched files +## Valid arguments: "Zulu8-32", "Zulu8-64", "Zulu11-32", or "Zulu11-64" +## +## java_zulu_install(String arch) +## +java_zulu_install(){ + local jdkBin + local jdkLib + local jdkArch - if is_x86_64; then - dpkg --add-architecture i386 - cond_redirect apt-get --yes install libc6:i386 libncurses5:i386 libstdc++6:i386 - fi + cond_redirect systemctl stop openhab2.service + cond_redirect java_alternatives_reset - elif [ "$1" == "Zulu8-64" ] || [ "$1" == "Zulu11-64" ]; then - if [ "$1" == "Zulu8-64" ]; then - echo -n "$(timestamp) [openHABian] Installing Java Zulu 8 64-Bit OpenJDK... " - link=$(fetch_zulu_tar_url Zulu8-64) - elif [ "$1" == "Zulu11-64" ]; then - echo -n "$(timestamp) [openHABian] Installing Java Zulu 11 64-Bit OpenJDK... " - link=$(fetch_zulu_tar_url Zulu11-64) - fi - if is_aarch64 && [ "$(getconf LONG_BIT)" == "64" ]; then - jdkArch="aarch64" - elif is_x86_64 && [ "$(getconf LONG_BIT)" == "64" ]; then - jdkArch="amd64" - else - if [ -n "$INTERACTIVE" ]; then - whiptail --title "Incompatible hardware detected" --msgbox "Zulu OpenJDK 64-bit: this option does not currently work on your platform.\\n\\nDefaulting to 32-bit installation." 10 60 - else - echo "Zulu OpenJDK 64-bit: this option does not currently work on your platform. Defaulting to Java Zulu 8 32-bit installation." - fi - link=$(fetch_zulu_tar_url Zulu8-32) - if is_arm; then - jdkArch="aarch32" - else - jdkArch="i386" - fi - fi + jdkBin=$(find /opt/jdk/*/bin ... -print -quit) + jdkLib=$(find /opt/jdk/*/lib ... -print -quit) + if is_arm; then + jdkArch="aarch32" + elif is_aarch64 && [ "$(getconf LONG_BIT)" == "64" ]; then + jdkArch="aarch64" + elif is_x86_64 && [ "$(getconf LONG_BIT)" == "64" ]; then + jdkArch="amd64" else - echo -n "[DEBUG] Invalid argument to function java_zulu_8_tar()" - exit 1 + jdkArch="i386" fi - jdkTempLocation="$(mktemp -d /tmp/openhabian.XXXXX)" - if [ -z "$jdkTempLocation" ]; then echo "FAILED"; exit 1; fi - jdkInstallLocation="/opt/jdk" - mkdir -p $jdkInstallLocation - # Fetch and copy new Java Zulu 8 runtime - cond_redirect wget -nv -O "$jdkTempLocation"/zulu8.tar.gz "$link" - tar -xpzf "$jdkTempLocation"/zulu8.tar.gz -C "${jdkTempLocation}" - if [ $? -ne 0 ]; then echo "FAILED"; rm -rf "$jdkTempLocation"/zulu8.tar.gz; exit 1; fi - rm -rf "$jdkTempLocation"/zulu8.tar.gz "${jdkInstallLocation:?}"/* - mv "${jdkTempLocation}"/* "${jdkInstallLocation}"/ + if is_aarch64; then + dpkg --add-architecture armhf + cond_redirect apt-get --yes install libc6:armhf libncurses5:armhf libstdc++6:armhf + fi - rmdir "${jdkTempLocation}" + if is_x86_64; then + dpkg --add-architecture i386 + cond_redirect apt-get --yes install libc6:i386 libncurses5:i386 libstdc++6:i386 + fi - # Update system with new installation - jdkLib=$(find "${jdkInstallLocation}"/*/lib ... -print -quit) - cond_redirect java_alternatives_reset "Zulu" - cond_redirect update-alternatives --remove-all javac ## TODO: remove sometime in late 2020 + update-alternatives --install /usr/bin/java java "$jdkBin"/java 1000000 + update-alternatives --install /usr/bin/jjs jjs "$jdkBin"/jjs 1000000 + update-alternatives --install /usr/bin/jrunscript jrunscript "$jdkBin"/jrunscript 1000000 + update-alternatives --install /usr/bin/keytool keytool "$jdkBin"/keytool 1000000 + update-alternatives --install /usr/bin/pack200 pack200 "$jdkBin"/pack200 1000000 + update-alternatives --install /usr/bin/rmid rmid "$jdkBin"/rmid 1000000 + update-alternatives --install /usr/bin/rmiregistry rmiregistry "$jdkBin"/rmiregistry 1000000 + update-alternatives --install /usr/bin/unpack200 unpack200 "$jdkBin"/unpack200 1000000 + update-alternatives --install /usr/bin/jexec jexec "$jdkLib"/jexec 1000000 echo "$jdkLib"/"$jdkArch" > /etc/ld.so.conf.d/java.conf echo "$jdkLib"/"$jdkArch"/jli >> /etc/ld.so.conf.d/java.conf ldconfig cond_redirect java_zulu_install_crypto_extension - if [ $? -eq 0 ]; then echo "OK"; else echo "FAILED"; exit 1; fi + if [ $? -eq 0 ]; then echo "OK"; else echo "FAILED"; return 1; fi cond_redirect systemctl start openhab2.service -} - -## Install Azul's Java Zulu Enterprise using APT repository. -## (package manager distributions only available on x86-64bit platforms when checked in April 2020) -## Valid arguments: "8" or "11" -## -## java_zulu_enterprise_apt(String ver) -## -java_zulu_enterprise_apt(){ - if [ "$1" == "8" ]; then - if ! dpkg -s 'zulu-8' > /dev/null 2>&1; then # Check if already is installed - echo -n "$(timestamp) [openHABian] Adding Zulu keys to apt... " - cond_redirect apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 219BD9C9 - if [ $? -ne 0 ]; then echo "FAILED (keyserver)"; exit 1; fi - cond_redirect systemctl stop openhab2.service - echo -n "$(timestamp) [openHABian] Installing Zulu 8 Enterprise 64-Bit OpenJDK... " - echo "deb http://repos.azulsystems.com/debian stable main" > /etc/apt/sources.list.d/zulu-enterprise.list - cond_redirect apt-get update - if cond_redirect apt-get --yes install zulu-8 && java_zulu_install_crypto_extension; then echo "OK"; else echo "FAILED"; exit 1; fi - cond_redirect systemctl start openhab2.service - fi - elif [ "$1" == "11" ]; then - if ! dpkg -s 'zulu-11' > /dev/null 2>&1; then # Check if already is installed - echo -n "$(timestamp) [openHABian] Adding Zulu keys to apt... " - cond_redirect apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 219BD9C9 - if [ $? -ne 0 ]; then echo "FAILED (keyserver)"; exit 1; fi - cond_redirect systemctl stop openhab2.service - echo -n "$(timestamp) [openHABian] Installing Zulu 11 Enterprise 64-Bit OpenJDK... " - echo "deb http://repos.azulsystems.com/debian stable main" > /etc/apt/sources.list.d/zulu-enterprise.list - cond_redirect apt-get update - if cond_redirect apt-get --yes install zulu-11 && java_zulu_install_crypto_extension; then echo "OK"; else echo "FAILED"; exit 1; fi - cond_redirect systemctl start openhab2.service - fi - fi + return 0 } ## Fetch Java Zulu 8 directly from Azul API v1 ## Valid arguments: "Zulu8-32", "Zulu8-64", "Zulu11-32", or "Zulu11-64" ## -## fetch_zulu_tar_url(String arch) +## java_zulu_fetch(String arch) ## -fetch_zulu_tar_url(){ +java_zulu_fetch(){ local link8 local link11 local downloadlink + local jdkInstallLocation + local jdkTempLocation link8="https://api.azul.com/zulu/download/community/v1.0/bundles/latest/binary/?jdk_version=8&ext=tar.gz&os=linux" link11="https://api.azul.com/zulu/download/community/v1.0/bundles/latest/binary/?jdk_version=11&ext=tar.gz&os=linux" @@ -221,12 +227,21 @@ fetch_zulu_tar_url(){ fi else - echo -n "[DEBUG] Invalid argument to function fetch_zulu_tar_url()" - exit 1 + echo -n "[DEBUG] Invalid argument to function java_zulu_fetch()" + return 1 fi - if [ -z "$downloadlink" ]; then return 1; fi - echo "$downloadlink" + + jdkInstallLocation="/opt/jdk" + mkdir -p $jdkInstallLocation + jdkTempLocation="$(mktemp -d /tmp/openhabian.XXXXX)" + if [ -z "$jdkTempLocation" ]; then echo "FAILED"; return 1; fi + cond_redirect wget -nv -O "$jdkTempLocation"/zulu8.tar.gz "$downloadlink" + tar -xpzf "$jdkTempLocation"/zulu8.tar.gz -C "${jdkTempLocation}" + if [ $? -ne 0 ]; then echo "FAILED"; rm -rf "$jdkTempLocation"/zulu8.tar.gz; return 1; fi + rm -rf "$jdkTempLocation"/zulu8.tar.gz "${jdkInstallLocation:?}"/* + mv "${jdkTempLocation}"/* "${jdkInstallLocation}"/ + rmdir "${jdkTempLocation}" return 0 } @@ -234,12 +249,14 @@ fetch_zulu_tar_url(){ ## Returns 0 / true if new version exists ## Valid arguments: "Zulu8-32", "Zulu8-64", "Zulu11-32", or "Zulu11-64" ## -## java_zulu_tar_update_available(String arch) +## java_zulu_update_available(String arch) ## -java_zulu_tar_update_available(){ - if [ ! -x "$(command -v java)" ] || [[ "$(java -version 2>&1)" == *"AdoptOpenJDK"* ]]; then return 0; fi +java_zulu_update_available(){ + if [ ! -x "$(command -v java)" ] || [[ "$(java -version 2>&1> /dev/null)" == *"AdoptOpenJDK"* ]]; then return 0; fi local availableVersion + local requestedArch local javaVersion + local javaArch local filter local link8 local link11 @@ -250,46 +267,93 @@ java_zulu_tar_update_available(){ filter='[.zulu_version[] | tostring] | join(".")' link8="https://api.azul.com/zulu/download/community/v1.0/bundles/latest/?jdk_version=8&ext=tar.gz&os=linux" link11="https://api.azul.com/zulu/download/community/v1.0/bundles/latest/?jdk_version=11&ext=tar.gz&os=linux" - javaVersion=$(java -version 2>&1 | grep -m 1 -o "[0-9]\{0,3\}\.[0-9]\{0,3\}\.[0-9]\{0,3\}\.[0-9]\{0,3\}") + javaVersion=$("$(find /opt/jdk/*/bin ... -print -quit)"/java -version |& grep -m 1 -o "[0-9]\{0,3\}\.[0-9]\{0,3\}\.[0-9]\{0,3\}\.[0-9]\{0,3\}") if [ "$1" == "Zulu8-32" ]; then if is_arm; then + requestedArch="aarch32hf" availableVersion=$(curl -s -H "Accept: application/json" "${link8}&arch=arm&hw_bitness=32" | jq -r "$filter") else + requestedArch="i686" availableVersion=$(curl -s -H "Accept: application/json" "${link8}&arch=x86&hw_bitness=32" | jq -r "$filter") fi elif [ "$1" == "Zulu11-32" ]; then if is_arm; then + requestedArch="aarch32hf" availableVersion=$(curl -s -H "Accept: application/json" "${link11}&arch=arm&hw_bitness=32" | jq -r "$filter") else + requestedArch="i686" availableVersion=$(curl -s -H "Accept: application/json" "${link11}&arch=x86&hw_bitness=32" | jq -r "$filter") fi elif [ "$1" == "Zulu8-64" ]; then if is_arm; then + requestedArch="aarch64" availableVersion=$(curl -s -H "Accept: application/json" "${link8}&arch=arm&hw_bitness=64" | jq -r "$filter") else + requestedArch="x64" availableVersion=$(curl -s -H "Accept: application/json" "${link8}&arch=x86&hw_bitness=64" | jq -r "$filter") fi elif [ "$1" == "Zulu11-64" ]; then if is_arm; then + requestedArch="aarch64" availableVersion=$(curl -s -H "Accept: application/json" "${link11}&arch=arm&hw_bitness=64" | jq -r "$filter") else + requestedArch="x64" availableVersion=$(curl -s -H "Accept: application/json" "${link11}&arch=x86&hw_bitness=64" | jq -r "$filter") fi else - if [ $? -ne 0 ]; then echo "FAILED (java update available)"; exit 1; fi + if [ $? -ne 0 ]; then echo "FAILED (java update available)"; return 1; fi fi - if [[ $javaVersion == "$availableVersion" ]]; then + if [[ "$("$(find /opt/jdk/*/bin ... -print -quit)"/java -version 2>&1> /dev/null)" == *"aarch32hf"* ]]; then javaArch="aarch32hf"; fi + if [[ "$("$(find /opt/jdk/*/bin ... -print -quit)"/java -version 2>&1> /dev/null)" == *"i686"* ]]; then javaArch="i686"; fi + if [[ "$("$(find /opt/jdk/*/bin ... -print -quit)"/java -version 2>&1> /dev/null)" == *"aarch64"* ]]; then javaArch="aarch64"; fi + if [[ "$("$(find /opt/jdk/*/bin ... -print -quit)"/java -version 2>&1> /dev/null)" == *"x64"* ]]; then javaArch="x64"; fi + + if [[ $javaVersion == "$availableVersion" ]] && [[ $javaArch == "$requestedArch" ]]; then return 1 # Java is up-to-date fi return 0 } +## Install Azul's Java Zulu Enterprise using APT repository. +## (package manager distributions only available on x86-64bit platforms when checked in April 2020) +## Valid arguments: "8" or "11" +## +## java_zulu_enterprise_apt(String ver) +## +java_zulu_enterprise_apt(){ + if [ "$1" == "8" ]; then + if ! dpkg -s 'zulu-8' > /dev/null 2>&1; then # Check if already is installed + echo -n "$(timestamp) [openHABian] Adding Zulu keys to apt... " + cond_redirect apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 219BD9C9 + if [ $? -ne 0 ]; then echo "FAILED (keyserver)"; return 1; fi + cond_redirect systemctl stop openhab2.service + echo -n "$(timestamp) [openHABian] Installing Zulu 8 Enterprise 64-Bit OpenJDK... " + echo "deb http://repos.azulsystems.com/debian stable main" > /etc/apt/sources.list.d/zulu-enterprise.list + cond_redirect apt-get update + if cond_redirect apt-get --yes install zulu-8 && java_zulu_install_crypto_extension; then echo "OK"; else echo "FAILED"; return 1; fi + cond_redirect systemctl start openhab2.service + fi + elif [ "$1" == "11" ]; then + if ! dpkg -s 'zulu-11' > /dev/null 2>&1; then # Check if already is installed + echo -n "$(timestamp) [openHABian] Adding Zulu keys to apt... " + cond_redirect apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 219BD9C9 + if [ $? -ne 0 ]; then echo "FAILED (keyserver)"; return 1; fi + cond_redirect systemctl stop openhab2.service + echo -n "$(timestamp) [openHABian] Installing Zulu 11 Enterprise 64-Bit OpenJDK... " + echo "deb http://repos.azulsystems.com/debian stable main" > /etc/apt/sources.list.d/zulu-enterprise.list + cond_redirect apt-get update + if cond_redirect apt-get --yes install zulu-11 && java_zulu_install_crypto_extension; then echo "OK"; else echo "FAILED"; return 1; fi + cond_redirect systemctl start openhab2.service + fi + fi +} + ## Install Zulu Cryptography Extension Kit to enable cryptos using more then 128 bits ## java_zulu_install_crypto_extension(){ @@ -300,11 +364,10 @@ java_zulu_install_crypto_extension(){ jdkSecurity="$(dirname "${jdkPath}")/../lib/security" mkdir -p "$jdkSecurity" policyTempLocation="$(mktemp -d /tmp/openhabian.XXXXX)" - if [ -z "$policyTempLocation" ]; then echo "FAILED"; exit 1; fi + if [ -z "$policyTempLocation" ]; then echo "FAILED"; return 1; fi cond_redirect wget -nv -O "$policyTempLocation"/crypto.zip https://cdn.azul.com/zcek/bin/ZuluJCEPolicies.zip cond_redirect unzip "$policyTempLocation"/crypto.zip -d "$policyTempLocation" - cp "$policyTempLocation"/ZuluJCEPolicies/*.jar "$jdkSecurity" rm -rf "${policyTempLocation}" return 0 @@ -313,7 +376,11 @@ java_zulu_install_crypto_extension(){ ## Fetch AdoptOpenJDK using APT repository. ## adoptopenjdk_fetch_apt(){ - local adoptKey="/tmp/adoptopenjdk.asc" + if ! dpkg -s 'software-properties-common' > /dev/null 2>&1; then + cond_redirect apt-get install --yes software-properties-common + fi + local adoptKey + adoptKey="/tmp/adoptopenjdk.asc" echo -n "$(timestamp) [openHABian] Adding AdoptOpenJDK keys to apt... " cond_redirect wget -qO "$adoptKey" https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public if cond_redirect apt-key add "$adoptKey"; then @@ -321,12 +388,13 @@ adoptopenjdk_fetch_apt(){ else echo "FAILED (keyserver)" rm -f "$adoptKey" - exit 1; + return 1; fi echo -n "$(timestamp) [openHABian] Fetching AdoptOpenJDK... " echo "deb http://adoptopenjdk.jfrog.io/adoptopenjdk/deb buster main" > /etc/apt/sources.list.d/adoptopenjdk.list cond_redirect apt-get update - if cond_redirect apt-get install --download-only adoptopenjdk-11-hotspot-jre; then echo "OK"; else echo "FAILED"; exit 1; fi + if cond_redirect apt-get install --download-only --yes adoptopenjdk-11-hotspot-jre; then echo "OK"; else echo "FAILED"; return 1; fi + return 0 } ## Install AdoptOpenJDK using APT repository. @@ -337,51 +405,30 @@ adoptopenjdk_install_apt(){ adoptopenjdk_fetch_apt cond_redirect systemctl stop openhab2.service cond_redirect java_alternatives_reset - if cond_redirect apt-get install --yes adoptopenjdk-11-hotspot-jre; then echo "OK"; else echo "FAILED"; exit 1; fi + if cond_redirect apt-get install --yes adoptopenjdk-11-hotspot-jre; then echo "OK"; else echo "FAILED"; return 1; fi cond_redirect systemctl start openhab2.service - elif dpkg -s 'adoptopenjdk-11-hotspot-jre' >/dev/null 2>&1; then + elif dpkg -s 'adoptopenjdk-11-hotspot-jre' > /dev/null 2>&1; then echo -n "$(timestamp) [openHABian] Reconfiguring AdoptOpenJDK 11... " cond_redirect systemctl stop openhab2.service cond_redirect java_alternatives_reset - if cond_redirect dpkg-reconfigure adoptopenjdk-11-hotspot-jre; then echo "OK"; else echo "FAILED"; exit 1; fi + if cond_redirect dpkg-reconfigure adoptopenjdk-11-hotspot-jre; then echo "OK"; else echo "FAILED"; return 1; fi cond_redirect systemctl start openhab2.service fi + return 0 } ## Reset Java in update-alternatives -## Valid arguments: "Zulu" -## -## java_alternatives_reset(String opt) ## java_alternatives_reset(){ update-alternatives --remove-all java update-alternatives --remove-all jjs + update-alternatives --remove-all jrunscript update-alternatives --remove-all keytool - update-alternatives --remove-all orbd update-alternatives --remove-all pack200 update-alternatives --remove-all policytool update-alternatives --remove-all rmid update-alternatives --remove-all rmiregistry - update-alternatives --remove-all servertool - update-alternatives --remove-all tnameserv update-alternatives --remove-all unpack200 update-alternatives --remove-all jexec - if [[ "$1" == "Zulu" ]]; then - local jdkBin - local jdkLib - jdkBin=$(find /opt/jdk/*/bin ... -print -quit) - jdkLib=$(find /opt/jdk/*/lib ... -print -quit) - update-alternatives --install /usr/bin/java java "$jdkBin"/java 1000000 - update-alternatives --install /usr/bin/jjs jjs "$jdkBin"/jjs 1000000 - update-alternatives --install /usr/bin/keytool keytool "$jdkBin"/keytool 1000000 - update-alternatives --install /usr/bin/orbd orbd "$jdkBin"/orbd 1000000 - update-alternatives --install /usr/bin/pack200 pack200 "$jdkBin"/pack200 1000000 - update-alternatives --install /usr/bin/policytool policytool "$jdkBin"/policytool 1000000 - update-alternatives --install /usr/bin/rmid rmid "$jdkBin"/rmid 1000000 - update-alternatives --install /usr/bin/rmiregistry rmiregistry "$jdkBin"/rmiregistry 1000000 - update-alternatives --install /usr/bin/servertool servertool "$jdkBin"/servertool 1000000 - update-alternatives --install /usr/bin/tnameserv tnameserv "$jdkBin"/tnameserv 1000000 - update-alternatives --install /usr/bin/unpack200 unpack200 "$jdkBin"/unpack200 1000000 - update-alternatives --install /usr/bin/jexec jexec "$jdkLib"/jexec 1000000 - fi + update-alternatives --remove-all javac # TODO: remove sometime late 2020 } diff --git a/functions/java-jre.bats b/functions/java-jre.bats index 10bebeaf2..e2bfa441f 100644 --- a/functions/java-jre.bats +++ b/functions/java-jre.bats @@ -3,119 +3,66 @@ load java-jre load helpers -@test "installation-java_exist" { - run java -version - [ "$status" -eq 0 ] - [[ $output == *"Zulu"* ]] -} - -@test "unit-zulu8-32_fetch_tar_url" { - run fetch_zulu_tar_url Zulu8-32 - echo "# Fetched .tar.gz download link for Java Zulu 8 32-bit: $output" - curl -s --head "$output" | head -n 1 | grep "HTTP/1.[01] [23].." > /dev/null # Check if link is valid, result it $? - [ $? -eq 0 ] -} - -@test "unit-zulu11-32_fetch_tar_url" { - run fetch_zulu_tar_url Zulu11-32 - echo "# Fetched .tar.gz download link for Java Zulu 11 32-bit: $output" - curl -s --head "$output" | head -n 1 | grep "HTTP/1.[01] [23].." > /dev/null # Check if link is valid, result it $? - [ $? -eq 0 ] -} - -@test "unit-zulu8-64_fetch_tar_url" { - run fetch_zulu_tar_url Zulu8-64 - echo "# Fetched .tar.gz download link for Java Zulu 8 64-bit: $output" - curl -s --head "$output" | head -n 1 | grep "HTTP/1.[01] [23].." > /dev/null # Check if link is valid, result it $? - [ $? -eq 0 ] +setup() { + rm -rf /etc/apt/sources.list.d/* } -@test "unit-zulu11-64_fetch_tar_url" { - run fetch_zulu_tar_url Zulu11-64 - echo "# Fetched .tar.gz download link for Java Zulu 11 64-bit: $output" - curl -s --head "$output" | head -n 1 | grep "HTTP/1.[01] [23].." > /dev/null # Check if link is valid, result it $? - [ $? -eq 0 ] -} - -@test "destructive-update_zulu8-64bit_tar" { +@test "destructive-install_zulu8-64bit" { echo -e "# \e[36mZulu 8 64-bit Java installation is being (test-)installed..." >&3 case "$(uname -m)" in aarch64|arm64|x86_64|amd64) ;; *) skip ;; esac - run systemctl start openhab2 - run java_zulu_tar Zulu8-64 - echo -e "# \e[32mZulu 8 64-bit Java installation successful." >&3 + run java_zulu_fetch Zulu8-64 + if [ "$status" -ne 0 ]; then echo "$output" >&3; fi [ "$status" -eq 0 ] - echo -e "# \e[32mZulu 8 64-bit Java installation successful." >&3 - run systemctl is-active --quiet openhab2 + run java_zulu_install + if [ "$status" -ne 0 ]; then echo "$output" >&3; fi [ "$status" -eq 0 ] - run java -version - [ "$status" -eq 0 ] - [[ $output == *"Zulu"* ]] - [[ $output == *"64"* ]] + echo -e "# \e[32mZulu 8 64-bit Java installation successful." >&3 } -@test "destructive-update_zulu11-64bit_tar" { +@test "destructive-install_zulu11-64bit" { echo -e "# \e[36mZulu 11 64-bit Java installation is being (test-)installed..." >&3 case "$(uname -m)" in aarch64|arm64|x86_64|amd64) ;; *) skip ;; esac - run systemctl start openhab2 - run java_zulu_tar Zulu11-64 - echo -e "# \e[32mZulu 11 64-bit Java installation successful." >&3 + run java_zulu_fetch Zulu11-64 + if [ "$status" -ne 0 ]; then echo "$output" >&3; fi [ "$status" -eq 0 ] - echo -e "# \e[32mZulu 11 64-bit Java installation successful." >&3 - run systemctl is-active --quiet openhab2 - [ "$status" -eq 0 ] - run java -version + run java_zulu_install + if [ "$status" -ne 0 ]; then echo "$output" >&3; fi [ "$status" -eq 0 ] - [[ $output == *"Zulu"* ]] - [[ $output == *"64"* ]] + echo -e "# \e[32mZulu 11 64-bit Java installation successful." >&3 } -@test "destructive-update_zulu8-32bit_tar" { +@test "destructive-install_zulu8-32bit" { echo -e "# \e[36mZulu 8 32-bit Java installation is being (test-)installed..." >&3 - run systemctl start openhab2 - run java_zulu_tar Zulu8-32 - echo -e "# \e[32mZulu 8 32-bit Java installation successful." >&3 + run java_zulu_fetch Zulu8-32 + if [ "$status" -ne 0 ]; then echo "$output" >&3; fi [ "$status" -eq 0 ] - echo -e "# \e[32mZulu 8 32-bit Java installation successful." >&3 - run systemctl is-active --quiet openhab2 - [ "$status" -eq 0 ] - run java -version + run java_zulu_install + if [ "$status" -ne 0 ]; then echo "$output" >&3; fi [ "$status" -eq 0 ] - [[ $output == *"Zulu"* ]] - [[ $output == *"32"* ]] + echo -e "# \e[32mZulu 8 32-bit Java installation successful." >&3 } -@test "destructive-update_zulu11-32bit_tar" { +@test "destructive-install_zulu11-32bit" { echo -e "# \e[36mZulu 11 32-bit Java installation is being (test-)installed..." >&3 - run systemctl start openhab2 - run java_zulu_tar Zulu11-32 - echo -e "# \e[32mZulu 11 32-bit Java installation successful." >&3 - [ "$status" -eq 0 ] - echo -e "# \e[32mZulu 11 32-bit Java installation successful." >&3 - run systemctl is-active --quiet openhab2 + run java_zulu_fetch Zulu11-32 + if [ "$status" -ne 0 ]; then echo "$output" >&3; fi [ "$status" -eq 0 ] - run java -version + run java_zulu_install + if [ "$status" -ne 0 ]; then echo "$output" >&3; fi [ "$status" -eq 0 ] - [[ $output == *"Zulu"* ]] - [[ $output == *"32"* ]] + echo -e "# \e[32mZulu 11 32-bit Java installation successful." >&3 } @test "destructive-install_adopt" { - echo -e "# \e[36mAdoptOpenJDK Java installation is being (test-)installed..." >&3 - run systemctl start openhab2 - run adoptopenjdk_fetch_apt + echo -e "# \e[36mAdoptOpenJDK 11 Java installation is being (test-)installed..." >&3 run adoptopenjdk_install_apt - echo -e "# \e[32mAdoptOpenJDK Java installation successful." >&3 - [ "$status" -eq 0 ] - echo -e "# \e[32mAdoptOpenJDK Java installation successful." >&3 - run systemctl is-active --quiet openhab2 - [ "$status" -eq 0 ] - run java -version + if [ "$status" -ne 0 ]; then echo "$output" >&3; fi [ "$status" -eq 0 ] - [[ $output == *"AdoptOpenJDK"* ]] + echo -e "# \e[32mAdoptOpenJDK 11 Java installation successful." >&3 } diff --git a/functions/menu.bash b/functions/menu.bash index cf1ec7b31..c0a6ff186 100644 --- a/functions/menu.bash +++ b/functions/menu.bash @@ -145,7 +145,7 @@ show_main_menu() { " | Default order" "Reset config load order to default (random)" \ "45 | Zulu 8 OpenJDK 32-bit" "Install Zulu 8 32-bit OpenJDK as primary Java provider" \ " | Zulu 8 OpenJDK 64-bit" "Install Zulu 8 64-bit OpenJDK as primary Java provider" \ - " | Zulu 11 OpenJDK 64-bit" "Install Zulu 11 64-bit OpenJDK as primary Java provider (beta)" \ + " | Zulu 11 OpenJDK 32-bit" "Install Zulu 11 32-bit OpenJDK as primary Java provider (beta)" \ " | Zulu 11 OpenJDK 64-bit" "Install Zulu 11 64-bit OpenJDK as primary Java provider (beta)" \ " | AdoptOpenJDK 11" "Install AdoptOpenJDK 11 as primary Java provider (beta)" \ 3>&1 1>&2 2>&3) @@ -164,7 +164,7 @@ show_main_menu() { *Zulu\ 8\ OpenJDK\ 64-bit) update_config_java "Zulu8-64" && java_install_or_update "Zulu8-64";; *Zulu\ 11\ OpenJDK\ 32-bit) update_config_java "Zulu11-32" && java_install_or_update "Zulu11-32";; *Zulu\ 11\ OpenJDK\ 64-bit) update_config_java "Zulu11-64" && java_install_or_update "Zulu11-64";; - *AdoptOpenJDK\ 11) update_config_java "AdoptOpenJDK" && java_install_or_update "AdoptOpenJDK";; + *AdoptOpenJDK\ 11) update_config_java "Adopt11" && java_install_or_update "Adopt11";; "") return 0 ;; *) whiptail --msgbox "A not supported option was selected (probably a programming error):\\n \"$choice2\"" 8 80 ;; esac @@ -200,7 +200,7 @@ show_main_menu() { "67 | Log Viewer" "The openHAB Log Viewer webapp (frontail) " OFF \ "68 | FireMotD" "Configure FireMotD to present a system overview on SSH login (optional) " OFF \ "69 | Bash&Vim Settings" "Apply openHABian settings for bash, vim and nano (optional) " OFF \ - "6A | Use ZRAM" "Use compressed RAM/disk sync for active directories (reduces SD card wear)" OFF \ + "6A | Use ZRAM" "Use compressed RAM/disk sync for active directories (mitigates SD card wear)" OFF \ " | Uninstall ZRAM" "Don't use compressed memory (back to standard Raspbian filesystem layout)" OFF \ 3>&1 1>&2 2>&3) if [ $? -eq 1 ] || [ $? -eq 255 ]; then return 0; fi @@ -211,7 +211,7 @@ show_main_menu() { if [[ $choosenComponents == *"Zulu 8 OpenJDK 64-bit"* ]]; then update_config_java "Zulu8-64" && java_install_or_update "Zulu8-64"; fi if [[ $choosenComponents == *"Zulu 11 OpenJDK 32-bit"* ]]; then update_config_java "Zulu11-32" && java_install_or_update "Zulu11-32"; fi if [[ $choosenComponents == *"Zulu 11 OpenJDK 64-bit"* ]]; then update_config_java "Zulu11-64" && java_install_or_update "Zulu11-64"; fi - if [[ $choosenComponents == *"AdoptOpenJDK 11"* ]]; then update_config_java "AdoptOpenJDK" && java_install_or_update "AdoptOpenJDK"; fi + if [[ $choosenComponents == *"AdoptOpenJDK 11"* ]]; then update_config_java "Adopt11" && java_install_or_update "Adopt11"; fi if [[ $choosenComponents == *"64"* ]]; then openhab2_setup; fi if [[ $choosenComponents == *"openHAB testing"* ]]; then openhab2_setup testing; fi if [[ $choosenComponents == *"openHAB unstable"* ]]; then openhab2_setup unstable; fi diff --git a/functions/openhabian.bash b/functions/openhabian.bash index a0ff30a2a..1f28c5127 100644 --- a/functions/openhabian.bash +++ b/functions/openhabian.bash @@ -173,4 +173,3 @@ disable_ipv6() { sed -i "s/^${IPV6_ENABLE}.*/# ${IPV6_ENABLE}/g" "${SYSCTL_INIT}" fi } - diff --git a/functions/system.bash b/functions/system.bash index d2882230d..b84588c72 100644 --- a/functions/system.bash +++ b/functions/system.bash @@ -11,7 +11,7 @@ system_upgrade() { echo -n "$(timestamp) [openHABian] Updating repositories and upgrading installed packages... " cond_redirect apt-get --yes upgrade # shellcheck disable=SC2154 - if cond_redirect java_install_or_update "$java_opt"; then echo "OK"; else echo "FAILED"; exit 1; fi + if cond_redirect java_install_or_update "$java_opt"; then echo "OK"; else echo "FAILED"; return 1; fi } basic_packages() { diff --git a/functions/wifi.bash b/functions/wifi.bash index f8ccf3b3c..c06341811 100644 --- a/functions/wifi.bash +++ b/functions/wifi.bash @@ -12,14 +12,14 @@ wifi_setup() { if [ -n "$INTERACTIVE" ]; then if grep -q "^[[:space:]]*dtoverlay=disable-wifi" /boot/config.txt; then - if (whiptail --title "WiFi is currently disabled" --yesno "WiFi is currently disabled on your box. Enable ?" 7 55); then + if (whiptail --title "WiFi is currently disabled" --yesno "WiFi is currently disabled on your box. Enable ?" 7 55); then cond_echo "Removing 'dtoverlay=disable-wifi' from /boot/config.txt" sed -i '/^[[:space:]]*dtoverlay=disable-wifi/d' /boot/config.txt whiptail --title "Operation Successful!" --msgbox "Please reboot now to enable your WiFi hardware.\\nRun openhabian-config and select this menu option again to continue." 8 75 fi return 0 else - if (whiptail --title "WiFi is currently ON" --defaultno --yesno "WiFi is currently enabled on your box.\\n\\nATTENTION:\\nDo you want to disable it ?" 10 50); then + if (whiptail --title "WiFi is currently ON" --defaultno --yesno "WiFi is currently enabled on your box.\\n\\nATTENTION:\\nDo you want to disable it ?" 10 50); then cond_echo "Adding 'dtoverlay=disable-wifi' to /boot/config.txt (RPi0W/3/4)" echo "dtoverlay=disable-wifi" >> /boot/config.txt whiptail --title "Operation successful!" --msgbox "Please reboot now to have your WiFi hardware disabled." 7 70 diff --git a/functions/zram.bats b/functions/zram.bats index efbd6249a..29800e749 100644 --- a/functions/zram.bats +++ b/functions/zram.bats @@ -1,4 +1,4 @@ -#!/usr/bin/env bats +#!/usr/bin/env bats load helpers load zram diff --git a/includes/nginx.conf b/includes/nginx.conf index 16529ad42..3364b62ac 100644 --- a/includes/nginx.conf +++ b/includes/nginx.conf @@ -21,7 +21,7 @@ server { add_header 'Access-Control-Allow_Credentials' 'true' always; add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range' always; add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH' always; - + ## Secure Certificate Locations #CERT ssl_certificate CERTPATH; #CERT ssl_certificate_key KEYPATH; diff --git a/openhabian.conf.dist b/openhabian.conf.dist index 8e0a1d5ac..8022f7603 100644 --- a/openhabian.conf.dist +++ b/openhabian.conf.dist @@ -51,7 +51,7 @@ mode=unattended #release=buster # Java architecture mode -# Valid arguments: "AdoptOpenJDK", "Zulu8-32", "Zulu8-64", "Zulu11-32", or "Zulu11-64" +# Valid arguments: "Adopt11", "Zulu8-32", "Zulu8-64", "Zulu11-32", or "Zulu11-64" java_opt=Zulu8-32 # vim: filetype=sh diff --git a/test.bash b/test.bash index ffee9a8bc..c5333146c 100755 --- a/test.bash +++ b/test.bash @@ -36,7 +36,7 @@ if [ "$1" == "docker-full" ]; then cond_redirect docker build --tag openhabian/openhabian-bats . cond_redirect docker run -it openhabian/openhabian-bats bash -c 'bats -r -f "unit-." .' cond_redirect docker run --name "install-test" --privileged -d openhabian/openhabian-bats - cond_redirect docker exec -it install-test bash -c "./build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local" + cond_redirect docker exec -it install-test bash -c "./build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local" cond_redirect docker exec -it install-test bash -c 'bats -r -f "installation-." .' cond_redirect docker exec -it install-test bash -c 'bats -r -f "destructive-." .' echo_process "Test complete, please review result in terminal. Access tested container by executing: \"docker exec -it install-test bash\""