diff --git a/.travis.yml b/.travis.yml index 1f845d7c2..bfa2ad25c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,7 @@ jobs: env: aarch64 arch: arm64 script: - - sed -i 's/java_arch=32-bit$/java_arch=64-bit/' build-image/openhabian.conf + - sed -i 's/^java_opt=.*/java_opt=Zulu64/' build-image/openhabian.conf - docker build -t openhabian/dev-openhabian -f Dockerfile.openhabian-aarch64-native . - docker run -i openhabian/dev-openhabian bash -c '/usr/local/bin/bats -r -f "dev-." .' - docker run -i openhabian/dev-openhabian bash -c '/usr/local/bin/bats -r -f "unit-." .' @@ -58,7 +58,7 @@ jobs: script: # 64bit Azul Java native on 64bit x86 on 64bit OS on Travis AMD64 HW - export HW=x86 - - sed -i 's/java_arch=32-bit$/java_arch=64-bit/' build-image/openhabian.conf + - sed -i 's/^java_opt=.*/java_opt=Zulu64/' build-image/openhabian.conf - docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-x86 . - echo -e "\n\e[36mopenHABian test installation 64bit Azul Enterprise Java on virtual $HW ...\n" - docker run --name "openhabian-${HW}" -d openhabian/${HW}-openhabian; @@ -68,7 +68,7 @@ jobs: script: # 32bit Azul Java on 32bit ARMv6hf (RPi0(W) and RPi1) on 32bit OS on Travis Arm64 HW - export HW=rpi01 - - sed -i 's/java_arch=64-bit$/java_arch=32-bit/' build-image/openhabian.conf + - sed -i 's/^java_opt=.*/java_opt=Zulu32/' build-image/openhabian.conf - docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-ARMv6hf-native . - echo -e "\n\e[36mopenHABian test installation 32bit Azul Embedded Java on virtual $HW ...\n" - docker run --name "openhabian-${HW}" -d openhabian/${HW}-openhabian; @@ -78,7 +78,7 @@ jobs: script: # 32bit Azul Java on 32bit ARMv7l (RPi2) on 32bit OS on Travis Arm64 HW - export HW=rpi2 - - sed -i 's/java_arch=64-bit$/java_arch=32-bit/' build-image/openhabian.conf + - sed -i 's/^java_opt=.*/java_opt=Zulu32/' build-image/openhabian.conf - docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-arm32hf-native . - echo -e "\n\e[36mopenHABian test installation 32bit Azul Embedded Java on virtual $HW ...\n" - docker run --memory="1g" --memory-reservation="1g" --name "openhabian-${HW}" -d openhabian/${HW}-openhabian @@ -88,7 +88,7 @@ jobs: script: # 32bit Azul Java on 64bit ARMv8 (CM3, RPi3) on 32bit OS on Travis Arm64 HW - export HW=cm3 - - sed -i 's/java_arch=64-bit$/java_arch=32-bit/' build-image/openhabian.conf + - sed -i 's/^java_opt=.*/java_opt=Zulu32/' build-image/openhabian.conf - docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-arm32hf-CM3 . - echo -e "\n\e[36mopenHABian test installation 32bit Azul Embedded Java on virtual $HW ...\n" - docker run --memory="1g" --memory-reservation="1g" --name "openhabian-${HW}" -d openhabian/${HW}-openhabian; @@ -99,7 +99,7 @@ jobs: # 64bit Azul Java on 32bit ARMv8 (RPi3, CM3) on 32bit OS on Travis Arm64 HW # This is known to not work - openHABian is supposed to downgrade to 32bit on install. - export HW=rpi3 - - sed -i 's/java_arch=32-bit$/java_arch=64-bit/' build-image/openhabian.conf + - sed -i 's/^java_opt=.*/java_opt=Zulu64/' build-image/openhabian.conf - docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-arm32hf-native . - echo -e "\n\e[36mopenHABian test installation 64bit Azul Embedded Java on virtual $HW ..." - echo -e "\e[31m ** This is known to not work. openHABian is supposed to force install down to 32bit **\n" @@ -111,7 +111,7 @@ jobs: # 64bit Azul Java on 64bit ARMv8 (RPi3,4) on 32bit OS on Travis Arm64 HW # This is known to not work - openHABian is supposed to downgrade to 32bit on install. - export HW=rpi3 - - sed -i 's/java_arch=32-bit$/java_arch=64-bit/' build-image/openhabian.conf + - sed -i 's/^java_opt=.*/java_opt=Zulu64/' build-image/openhabian.conf - docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-aarch64-native . - echo -e "\n\e[36mopenHABian test installation 64bit Azul Embedded Java on virtual $HW ..." - echo -e "\e[31m ** This is known to not work. openHABian is supposed to force install down to 32bit **\n" @@ -122,8 +122,18 @@ jobs: script: # 64bit Azul Java on 64bit ARMv8 (RPi3,4) on 64bit OS on Travis Arm64 HW - export HW=rpi4 - - sed -i 's/java_arch=32-bit$/java_arch=64-bit/' build-image/openhabian.conf + - sed -i 's/^java_opt=.*/java_opt=Zulu64/' build-image/openhabian.conf - docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-aarch64-64bit . - echo -e "\n\e[36mopenHABian test installation 64bit Azul Embedded Java \e[31m on 64bit OS\e[36m on virtual $HW ...\n" - docker run --memory="2G" --memory-reservation="2G" --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' + - env: aarch64 + arch: arm64 + 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 + - 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" + - 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/build-image/openhabian.conf b/build-image/openhabian.conf index 0199b36e1..deedc29a4 100644 --- a/build-image/openhabian.conf +++ b/build-image/openhabian.conf @@ -38,7 +38,7 @@ clonebranch=master mode=unattended # Java architecture mode -# values: "Zulu32", "Zulu64" or "AdoptOpenJDK" +# Valid arguments: "AdoptOpenJDK", "Zulu32", or "Zulu64" java_arch=32-bit # vim: filetype=sh diff --git a/build-image/openhabian.pi-raspbian.conf b/build-image/openhabian.pi-raspbian.conf index a016565f7..be653ca69 100644 --- a/build-image/openhabian.pi-raspbian.conf +++ b/build-image/openhabian.pi-raspbian.conf @@ -28,7 +28,7 @@ wifi_country="" # Eventually disable all IPv6 e.g. on installation problems # values: "enable", "disable" ipv6=enable - + # repo to clone from (if not master for build and test) repositoryurl=https://github.com/openhab/openhabian.git clonebranch=master @@ -38,7 +38,7 @@ clonebranch=master mode=unattended # Java architecture mode -# values: "Zulu32", "Zulu64" or "AdoptOpenJDK" +# Valid arguments: "AdoptOpenJDK", "Zulu32", or "Zulu64" java_arch=32-bit # vim: filetype=sh diff --git a/build-image/openhabian.pine64-xenial.conf b/build-image/openhabian.pine64-xenial.conf index 78ea6a1c9..681ae107f 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 -# Use 32-bit or 64-bit -java_arch=32-bit +# Valid arguments: "AdoptOpenJDK", "Zulu32", or "Zulu64" +java_opt=Zulu32 diff --git a/functions/config.bash b/functions/config.bash index 216516b07..e7fc22d39 100644 --- a/functions/config.bash +++ b/functions/config.bash @@ -31,19 +31,19 @@ clean_config_userpw() { } ## Update java architecture in config file -## Valid options: "32-bit" & "64-bit" +## Valid options: "Zulu32", "Zulu64", "AdoptOpenJDK" update_config_java() { - if [ "$1" == "64-bit" ]; then + if [ "$1" == "Zulu64" ]; then if (! is_x86_64 && ! [ "$(getconf LONG_BIT)" == "64" ]) || (! is_aarch64 && ! [ "$(getconf LONG_BIT)" == "64" ]); then 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 32-bit installation." fi - cond_redirect grep -q '^java_arch' "$CONFIGFILE" && sed -i "s/^java_arch.*/java_arch=32-bit/" "$CONFIGFILE" || echo "java_arch=32-bit" >> "$CONFIGFILE" + cond_redirect grep -q '^java_opt' "$CONFIGFILE" && sed -i "s/^java_opt.*/java_opt=Zulu32/" "$CONFIGFILE" || echo "java_opt=Zulu32" >> "$CONFIGFILE" fi else - cond_redirect grep -q '^java_arch' "$CONFIGFILE" && sed -i "s/^java_arch.*/java_arch=$1/" "$CONFIGFILE" || echo "java_arch=$1" >> "$CONFIGFILE" + cond_redirect grep -q '^java_opt' "$CONFIGFILE" && sed -i "s/^java_opt.*/java_opt=$1/" "$CONFIGFILE" || echo "java_opt=$1" >> "$CONFIGFILE" fi # shellcheck disable=SC1090 source "$CONFIGFILE" diff --git a/functions/helpers.bash b/functions/helpers.bash index 5e36dfe61..f7b8c5bbb 100644 --- a/functions/helpers.bash +++ b/functions/helpers.bash @@ -169,5 +169,5 @@ tryUntil() { echo -n ".${i}." ((i-=1)) done - return $i + return "$i" } diff --git a/functions/java-jre.bash b/functions/java-jre.bash index a07490e01..1b8a192ab 100644 --- a/functions/java-jre.bash +++ b/functions/java-jre.bash @@ -1,34 +1,44 @@ #!/usr/bin/env bash # shellcheck disable=SC2181 +# shellcheck disable=SC2144 -## Install appropriate Java version based on current platform. -## Valid arguments: 64-bit, 32-bit +## Install appropriate Java version based on current choice. +## Valid arguments: "AdoptOpenJDK", "Zulu32", or "Zulu64" ## -## java_install_and_update(String arch) +## java_install_and_update(String type) ## java_install_or_update(){ - # Make sure we don't overwrite existing non Java Zulu installations - if ! [ -x "$(command -v java)" ] || [[ ! "$(java -version)" == *"Zulu"* ]]; then - if [ "$1" == "64-bit" ]; then - if is_x86_64; then - java_zulu_enterprise_8_apt + # 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 java_zulu_tar_update_available 64-bit; then - java_zulu_8_tar 64-bit + if [ "$1" == "Zulu64" ]; then + if is_x86_64; then + java_zulu_enterprise_8_apt + else + if java_zulu_tar_update_available 64-bit; then + java_zulu_8_tar 64-bit + fi + fi + else # Default to 32-bit installation + if java_zulu_tar_update_available 32-bit; then + java_zulu_8_tar 32-bit + fi fi fi - - else # Default to 32-bit installation - if java_zulu_tar_update_available 32-bit; then - java_zulu_8_tar 32-bit - fi fi fi cond_redirect java -version } ## Install Java Zulu 8 directly from fetched .tar.gz file -## Valid arguments: 64-bit, 32-bit +## Valid arguments: "32-bit" or "64-bit" ## ## java_zulu_8_tar(String arch) ## @@ -36,7 +46,6 @@ java_zulu_8_tar(){ local link local jdkTempLocation local jdkInstallLocation - local jdkBin local jdkLib local jdkArch @@ -101,12 +110,9 @@ java_zulu_8_tar(){ rmdir "${jdkTempLocation}" # Update system with new installation - jdkBin=$(find "${jdkInstallLocation}"/*/bin ... -print -quit) jdkLib=$(find "${jdkInstallLocation}"/*/lib ... -print -quit) - cond_redirect update-alternatives --remove-all java - ## TODO: remove sometime in late 2020 - cond_redirect update-alternatives --remove-all javac - cond_redirect update-alternatives --install /usr/bin/java java "$jdkBin"/java 1083000 + cond_redirect java_alternatives_reset "Zulu" + cond_redirect update-alternatives --remove-all javac ## TODO: remove sometime in late 2020 echo "$jdkLib"/"$jdkArch" > /etc/ld.so.conf.d/java.conf echo "$jdkLib"/"$jdkArch"/jli >> /etc/ld.so.conf.d/java.conf ldconfig @@ -122,19 +128,20 @@ java_zulu_8_tar(){ ## java_zulu_enterprise_8_apt(){ if ! dpkg -s 'zulu-8' >/dev/null 2>&1; then # Check if already is installed - cond_redirect systemctl stop openhab2.service - echo -n "$(timestamp) [openHABian] Installing Zulu Enterprise 64-Bit OpenJDK... " - cond_redirect apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 219BD9C9 - if [ $? -ne 0 ]; then echo "FAILED (keyserver)"; exit 1; fi - 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 + 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 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 } ## Fetch Java Zulu 8 directly from Azul API v1 -## Valid arguments: 64-bit, 32-bit +## Valid arguments: "32-bit" or "64-bit" ## ## fetch_zulu_tar_url(String arch) ## @@ -170,12 +177,12 @@ fetch_zulu_tar_url(){ ## Check if a newer version of Java Zulu 8 is available. ## Returns 0 / true if new version exists -## Valid arguments: 64-bit, 32-bit +## Valid arguments: "32-bit" or "64-bit" ## ## java_zulu_tar_update_available(String arch) ## java_zulu_tar_update_available(){ - if [ ! -x "$(command -v java)" ]; then return 0; fi + if [ ! -x "$(command -v java)" ] || [[ "$(java -version 2>&1)" == *"AdoptOpenJDK"* ]]; then return 0; fi local availableVersion local javaVersion local filter @@ -231,3 +238,78 @@ java_zulu_install_crypto_extension(){ rm -rf "${policyTempLocation}" return 0 } + +## Fetch AdoptOpenJDK using APT repository. +## +adoptopenjdk_fetch_apt(){ + local 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 + echo "OK" + else + echo "FAILED (keyserver)" + rm -f "$adoptKey" + exit 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-8-hotspot-jre; then echo "OK"; else echo "FAILED"; exit 1; fi +} + +## Install AdoptOpenJDK using APT repository. +## +adoptopenjdk_install_apt(){ + if ! dpkg -s 'adoptopenjdk-8-hotspot-jre' > /dev/null 2>&1; then # Check if already is installed + echo -n "$(timestamp) [openHABian] Installing AdoptOpenJDK... " + adoptopenjdk_fetch_apt + cond_redirect systemctl stop openhab2.service + cond_redirect java_alternatives_reset + if cond_redirect apt-get install --yes adoptopenjdk-8-hotspot-jre; then echo "OK"; else echo "FAILED"; exit 1; fi + cond_redirect systemctl start openhab2.service + elif dpkg -s 'adoptopenjdk-8-hotspot-jre' >/dev/null 2>&1; then + cond_redirect systemctl stop openhab2.service + cond_redirect java_alternatives_reset + if cond_redirect dpkg-reconfigure adoptopenjdk-8-hotspot-jre; then echo "OK"; else echo "FAILED"; exit 1; fi + cond_redirect systemctl start openhab2.service + fi +} + +## 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 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 +} diff --git a/functions/java-jre.bats b/functions/java-jre.bats index cd6a469cb..e9408fa8e 100644 --- a/functions/java-jre.bats +++ b/functions/java-jre.bats @@ -49,3 +49,17 @@ load helpers [[ $output == *"Zulu"* ]] [[ $output == *"32"* ]] } + +@test "destructive-install_adopt" { + echo -e "# \e[36mAdoptOpenJDK Java installation is being (test-)installed..." >&3 + run systemctl start openhab2 + 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 + [ "$status" -eq 0 ] + [[ $output == *"AdoptOpenJDK"* ]] +} diff --git a/functions/menu.bash b/functions/menu.bash index d9be80a2b..26503da95 100644 --- a/functions/menu.bash +++ b/functions/menu.bash @@ -135,17 +135,21 @@ show_main_menu() { esac elif [[ "$choice" == "40"* ]]; then - choice2=$(whiptail --title "Welcome to the openHABian Configuration Tool $(get_git_revision)" --menu "Setup Options" 14 116 7 --cancel-button Back --ok-button Execute \ - "41 | openHAB release " "Install or switch to the latest openHAB release" \ - " | openHAB testing" "Install or switch to the latest openHAB testing build" \ - " | openHAB snapshot" "Install or switch to the latest openHAB SNAPSHOT build" \ - "42 | Remote Console" "Bind the openHAB SSH console to all external interfaces" \ - "43 | Reverse Proxy" "Setup Nginx with password authentication and/or HTTPS access" \ - "44 | Delay rules load" "Delay loading rules to speed up overall startup" \ - " | Default order" "Reset config load order to default (random)" \ + choice2=$(whiptail --title "Welcome to the openHABian Configuration Tool $(get_git_revision)" --menu "Setup Options" 18 116 11 --cancel-button Back --ok-button Execute \ + "41 | openHAB release" "Install or switch to the latest openHAB release" \ + " | openHAB testing" "Install or switch to the latest openHAB testing build" \ + " | openHAB snapshot" "Install or switch to the latest openHAB SNAPSHOT build" \ + "42 | Remote Console" "Bind the openHAB SSH console to all external interfaces" \ + "43 | Reverse Proxy" "Setup Nginx with password authentication and/or HTTPS access" \ + "44 | Delay rules load" "Delay loading rules to speed up overall startup" \ + " | Default order" "Reset config load order to default (random)" \ + "45 | Zulu OpenJDK 32-bit" "Install Zulu 32-bit OpenJDK as primary Java provider" \ + " | Zulu OpenJDK 64-bit" "Install Zulu 64-bit OpenJDK as primary Java provider" \ + " | AdoptOpenJDK" "Install AdoptOpenJDK as primary Java provider" \ 3>&1 1>&2 2>&3) if [ $? -eq 1 ] || [ $? -eq 255 ]; then return 0; fi wait_for_apt_to_finish_update + # shellcheck disable=SC2154 case "$choice2" in 41\ *) openhab2_setup ;; *openHAB\ testing) openhab2_setup testing ;; @@ -154,6 +158,9 @@ show_main_menu() { 43\ *) nginx_setup ;; *Delay\ rules\ load) delayed_rules yes;; *Default\ order) delayed_rules no;; + *Zulu\ OpenJDK\ 32-bit) update_config_java "Zulu32" && java_install_or_update "$java_opt";; + *Zulu\ OpenJDK\ 64-bit) update_config_java "Zulu64" && java_install_or_update "$java_opt";; + *AdoptOpenJDK) update_config_java "AdoptOpenJDK" && java_install_or_update "$java_opt";; "") return 0 ;; *) whiptail --msgbox "A not supported option was selected (probably a programming error):\\n \"$choice2\"" 8 80 ;; esac @@ -175,8 +182,6 @@ show_main_menu() { elif [[ "$choice" == "60"* ]]; then choosenComponents=$(whiptail --title "Manual/Fresh Setup" --checklist "Choose which system components to install or configure:" 20 116 13 --cancel-button Back --ok-button Execute \ "62 | Packages" "Install needed and recommended system packages " OFF \ - "63 | Zulu OpenJDK 32-bit" "Install Zulu OpenJDK Java 8 32-bit" OFF \ - " | Zulu OpenJDK 64-bit" "Install Zulu OpenJDK Java 8 64-bit" OFF \ "64 | openHAB stable" "Install the latest openHAB release" OFF \ " | openHAB testing" "Install the latest openHAB testing (milestone) build" OFF \ " | openHAB unstable" "(Alternative) Install the latest openHAB SNAPSHOT build" OFF \ @@ -191,9 +196,6 @@ show_main_menu() { if [ $? -eq 1 ] || [ $? -eq 255 ]; then return 0; fi wait_for_apt_to_finish_update if [[ $choosenComponents == *"62"* ]]; then apt-get upgrade -y && basic_packages && needed_packages; fi - # shellcheck disable=SC2154 - if [[ $choosenComponents == *"63"* ]]; then update_config_java "32-bit"; java_install_or_update "$java_arch"; fi - if [[ $choosenComponents == *"Zulu OpenJDK 64-bit"* ]]; then update_config_java "64-bit"; java_install_or_update "$java_arch"; 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/system.bash b/functions/system.bash index 025c75c77..2e46e5160 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_arch"; then echo "OK"; else echo "FAILED"; exit 1; fi + if cond_redirect java_install_or_update "$java_opt"; then echo "OK"; else echo "FAILED"; exit 1; fi } basic_packages() { diff --git a/openhabian-setup.sh b/openhabian-setup.sh index 5421deda2..25a304f63 100755 --- a/openhabian-setup.sh +++ b/openhabian-setup.sh @@ -88,7 +88,7 @@ if [[ -n "$UNATTENDED" ]]; then vimrc_copy firemotd_setup # shellcheck disable=SC2154 - java_install_or_update "$java_arch" + java_install_or_update "$java_opt" openhab2_setup vim_openhab_syntax nano_openhab_syntax diff --git a/openhabian.conf.dist b/openhabian.conf.dist index 268fa1f4a..e07c8e54d 100644 --- a/openhabian.conf.dist +++ b/openhabian.conf.dist @@ -37,7 +37,7 @@ clonebranch=master mode=unattended # Java architecture mode -# values: "Zulu32", "Zulu64" or "AdoptOpenJDK" +# Valid arguments: "AdoptOpenJDK", "Zulu32", or "Zulu64" java_arch=32-bit # vim: filetype=sh