Skip to content

Commit be05577

Browse files
authored
Refuse to install openHAB 5 if no Java 21 (after potential Java install) (#2020)
1 parent 658e387 commit be05577

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

functions/openhab.bash

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ openhab_setup() {
3131
local installVersion
3232
local repo
3333
local successText
34+
local noJVMText="We were unable to install/upgrade your system to openHAB 5.\\nThis requires Java version 21, and we have been unable to identify and install a suitable Java JVM package for your hardware-OS combo."
3435
local ohPkgName="openhab"
36+
local textsize=9
3537

3638
if [[ $1 == "snapshot" || $1 == "unstable" ]]; then
3739
introText="Proceed with caution!\\n\\nYou are about to switch over to the latest $ohPkgName unstable snapshot build. The daily snapshot builds contain the latest features and improvements but might also suffer from bugs or incompatibilities. Please be sure to take a full openHAB configuration backup first!\\n\\nBeware that downgrading will not be possible, you can only re-install old software and re-important the config backup you should have made before the upgrade."
@@ -58,7 +60,7 @@ openhab_setup() {
5860
fi
5961

6062
# date needs to be > Apr 1, 24 for openhab repo signing key to be valid
61-
# note RPi have no RTC
63+
# note RPis have no real time clock
6264
if [[ $(date +%y%m%d) -lt 240401 ]]; then
6365
systemctl stop systemd-timesyncd
6466
timedatectl set-time "2024-04-09 00:00:00"
@@ -89,6 +91,20 @@ openhab_setup() {
8991
fi
9092
fi
9193

94+
javaVersionNeu="$(java -version |& head -1 | awk -F'"' '{ print $2 }' | cut -d '.' -f1)"
95+
if [[ $openhabMajorVersion = 5 ]] && [[ $javaVersionNeu -lt 21 ]] ; then
96+
echo "FAILED (could not install required Java 21)"
97+
if [[ -n $INTERACTIVE ]]; then
98+
unset DEBIAN_FRONTEND
99+
if is_arm && [[ "$(getconf LONG_BIT)" == "32" ]]; then
100+
noJVMText+="\\n\\nThere is currently no suitable JVM package for ARM processors that works\\nwith a 32 bit OS image."
101+
textsize=12
102+
fi
103+
whiptail --title "Operation failed!" --msgbox "$noJVMText" ${textsize} 80
104+
fi
105+
return 1
106+
fi
107+
92108
if [[ -n $openhabVersion ]]; then
93109
installVersion="${ohPkgName}=${openhabVersion} ${ohPkgName}-addons=${openhabVersion}"
94110
else

0 commit comments

Comments
 (0)