-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not require Java presence for RPM installation
This allows for custom JDK to be used when running Trino with launcher --jvm-dir argument.
- Loading branch information
Showing
3 changed files
with
2 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,4 @@ | ||
# Pre installation script | ||
|
||
# Ensure that the proper version of Java exists on the system | ||
|
||
java_version() { | ||
# The one argument is the location of java (either $JAVA_HOME or a potential | ||
# candidate for JAVA_HOME. | ||
JAVA="$1"/bin/java | ||
"$JAVA" -version 2>&1 | grep "\(java\|openjdk\) version" | awk '{ print substr($3, 2, length($3)-2); }' | ||
} | ||
|
||
check_if_correct_java_version() { | ||
|
||
# If the string is empty return non-zero code. We don't want false positives if /bin/java is | ||
# a valid java version because that will leave JAVA_HOME unset and the init.d scripts will | ||
# use the default java version, which may not be the correct version. | ||
if [ -z "$1" ]; then | ||
return 1 | ||
fi | ||
|
||
# The one argument is the location of java (either $JAVA_HOME or a potential | ||
# candidate for JAVA_HOME). | ||
JAVA_VERSION=$(java_version "$1") | ||
JAVA_MAJOR=$(echo "$JAVA_VERSION" | cut -d'-' -f1 | cut -d'.' -f1) | ||
if [ "$JAVA_MAJOR" -ge "23" ]; then | ||
echo "$1" >/tmp/trino-rpm-install-java-home | ||
return 0 | ||
else | ||
return 1 | ||
fi | ||
} | ||
|
||
# if Java version of $JAVA_HOME is not correct, then try to find it again below | ||
if ! check_if_correct_java_version "$JAVA_HOME"; then | ||
java_found=false | ||
for candidate in \ | ||
/usr/lib/jvm/java-23-* \ | ||
/usr/lib/jvm/zulu-23 \ | ||
/usr/lib/jvm/temurin-23 \ | ||
/usr/lib/jvm/temurin-23-* \ | ||
/usr/lib/jvm/default-java \ | ||
/usr/java/default \ | ||
/ \ | ||
/usr; do | ||
if [ -e "$candidate"/bin/java ]; then | ||
if check_if_correct_java_version "$candidate"; then | ||
java_found=true | ||
break | ||
fi | ||
fi | ||
done | ||
fi | ||
|
||
# if no appropriate java found | ||
if [ "$java_found" = false ]; then | ||
cat 1>&2 <<EOF | ||
+======================================================================+ | ||
| Error: Required Java version could not be found | | ||
+----------------------------------------------------------------------+ | ||
| JDK 23 was not detected. | | ||
| Recommended JDK distribution is Eclipse Temurin. | | ||
| Installation guide: https://adoptium.net/installation/linux/ | | ||
| | | ||
| NOTE: This script will attempt to find Java whether you install | | ||
| using the binary or the RPM based installer. | | ||
+======================================================================+ | ||
EOF | ||
exit 1 | ||
fi | ||
|
||
getent group trino >/dev/null || /usr/sbin/groupadd -r trino | ||
getent passwd trino >/dev/null || /usr/sbin/useradd --comment "Trino" -s /sbin/nologin -g trino -r -d /var/lib/trino trino |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters