You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by sm...@apache.org on 2024/03/21 13:16:18 UTC
(knox) branch master updated: KNOX-3024 - Fixed Java finding issues (#891)
This is an automated email from the ASF dual-hosted git repository.
smolnar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git
The following commit(s) were added to refs/heads/master by this push:
new 1e9a39b76 KNOX-3024 - Fixed Java finding issues (#891)
1e9a39b76 is described below
commit 1e9a39b76b2da8d995f1201d9cf0ecf6b3d3d085
Author: Sandor Molnar <sm...@apache.org>
AuthorDate: Thu Mar 21 14:16:13 2024 +0100
KNOX-3024 - Fixed Java finding issues (#891)
---
gateway-release-common/home/bin/knox-functions.sh | 18 +++++++++++++++---
gateway-release/home/bin/gateway.sh | 3 +++
gateway-release/home/bin/knoxcli.sh | 3 +++
gateway-release/home/bin/ldap.sh | 3 +++
4 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/gateway-release-common/home/bin/knox-functions.sh b/gateway-release-common/home/bin/knox-functions.sh
index 1a5dc5cc6..726ff85a6 100644
--- a/gateway-release-common/home/bin/knox-functions.sh
+++ b/gateway-release-common/home/bin/knox-functions.sh
@@ -50,6 +50,17 @@ DEFAULT_APP_STATUS_TEST_RETRY_SLEEP=2
##### common functions #####
############################
+function setVerbose() {
+ export VERBOSE=false
+ for arg in "$@"; do
+ # Check if the argument contains the search string
+ if [[ $arg == *"--verbose"* ]]; then
+ export VERBOSE=true
+ break
+ fi
+ done
+}
+
JAVA_VERSION_PATTERNS=( "1.6.0_31/bin/java$" "1.6.0_.*/bin/java$" "1.6.0.*/bin/java$" "1.6\..*/bin/java$" "/bin/java$" )
function findJava() {
@@ -72,7 +83,7 @@ function findJava() {
# Try to find java on PATH.
if [ "$JAVA" == "" ]; then
- JAVA=$(command -v java 2>/dev/null)
+ JAVA=$(which java 2>/dev/null)
if [ ! -x "$JAVA" ]; then
JAVA=""
fi
@@ -82,9 +93,8 @@ function findJava() {
if [ "$JAVA" == "" ]; then
for pattern in "${JAVA_VERSION_PATTERNS[@]}"; do
# shellcheck disable=SC2207
- JAVAS=( $(find /usr -executable -name java -print 2> /dev/null | grep "$pattern" | head -n 1 ) )
+ JAVA=$(find /usr -executable -name java -print 2> /dev/null | grep "$pattern" | head -n 1 )
if [ -x "$JAVA" ]; then
- JAVA=${JAVAS[1]}
break
else
JAVA=""
@@ -98,6 +108,8 @@ function checkJava() {
if [[ -z $JAVA ]]; then
echo "Warning: JAVA is not set and could not be found." 1>&2
+ elif [[ "$VERBOSE" = "true" ]]; then
+ echo "Found Java at $JAVA"
fi
}
diff --git a/gateway-release/home/bin/gateway.sh b/gateway-release/home/bin/gateway.sh
index ba0ec178b..18b2287d5 100755
--- a/gateway-release/home/bin/gateway.sh
+++ b/gateway-release/home/bin/gateway.sh
@@ -26,9 +26,11 @@ APP_NAME=gateway
# Start/stop script location
APP_BIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+# shellcheck disable=SC1091
# Setup the common environment
. "$APP_BIN_DIR"/knox-env.sh
+# shellcheck disable=SC1091
# Source common functions
. "$APP_BIN_DIR"/knox-functions.sh
@@ -103,6 +105,7 @@ function startGateway() {
}
function main {
+ setVerbose "$@"
checkJava
case "$1" in
diff --git a/gateway-release/home/bin/knoxcli.sh b/gateway-release/home/bin/knoxcli.sh
index 08573c495..3477e70a4 100755
--- a/gateway-release/home/bin/knoxcli.sh
+++ b/gateway-release/home/bin/knoxcli.sh
@@ -26,9 +26,11 @@ APP_BIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# The app's jar name
APP_JAR="$APP_BIN_DIR/knoxcli.jar"
+# shellcheck disable=SC1091
# Setup the common environment
. "$APP_BIN_DIR"/knox-env.sh
+# shellcheck disable=SC1091
# Source common functions
. "$APP_BIN_DIR"/knox-functions.sh
@@ -72,6 +74,7 @@ function buildAppJavaOpts {
}
function main {
+ setVerbose "$@"
checkJava
buildAppJavaOpts
$JAVA "${APP_JAVA_OPTS[@]}" -jar "$APP_JAR" "$@" || exit 1
diff --git a/gateway-release/home/bin/ldap.sh b/gateway-release/home/bin/ldap.sh
index 763af6f6f..2d1678665 100755
--- a/gateway-release/home/bin/ldap.sh
+++ b/gateway-release/home/bin/ldap.sh
@@ -29,9 +29,11 @@ APP_BIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# The app's JAR name
export APP_JAR="$APP_BIN_DIR/ldap.jar"
+# shellcheck disable=SC1091
# Setup the common environment
. "$APP_BIN_DIR"/knox-env.sh
+# shellcheck disable=SC1091
# Source common functions
. "${APP_BIN_DIR}"/knox-functions.sh
@@ -65,6 +67,7 @@ DEFAULT_APP_RUNNING_IN_FOREGROUND="$LDAP_SERVER_RUN_IN_FOREGROUND"
export APP_RUNNING_IN_FOREGROUND=${KNOX_LDAP_RUNNING_IN_FOREGROUND:-$DEFAULT_APP_RUNNING_IN_FOREGROUND}
function main {
+ setVerbose "$@"
checkJava
case "$1" in