You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by km...@apache.org on 2014/02/17 22:51:04 UTC
git commit: KNOX-262: Improve JRE detection in scripting.
Repository: incubator-knox
Updated Branches:
refs/heads/master cae6a6dff -> de67dcb89
KNOX-262: Improve JRE detection in scripting.
Project: http://git-wip-us.apache.org/repos/asf/incubator-knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-knox/commit/de67dcb8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-knox/tree/de67dcb8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-knox/diff/de67dcb8
Branch: refs/heads/master
Commit: de67dcb890d0ed5a97c1073d8d79280707913e9e
Parents: cae6a6d
Author: Kevin Minder <ke...@hortonworks.com>
Authored: Mon Feb 17 16:49:53 2014 -0500
Committer: Kevin Minder <ke...@hortonworks.com>
Committed: Mon Feb 17 16:49:53 2014 -0500
----------------------------------------------------------------------
gateway-release/home/bin/gateway.sh | 12 +++---
gateway-release/home/bin/knox-env.sh | 61 +++++++++++++++++++++++++++++++
gateway-release/home/bin/knoxcli.sh | 8 ++--
gateway-release/home/bin/ldap.sh | 8 ++--
4 files changed, 75 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/de67dcb8/gateway-release/home/bin/gateway.sh
----------------------------------------------------------------------
diff --git a/gateway-release/home/bin/gateway.sh b/gateway-release/home/bin/gateway.sh
index ceb98a9..4de979b 100755
--- a/gateway-release/home/bin/gateway.sh
+++ b/gateway-release/home/bin/gateway.sh
@@ -64,15 +64,15 @@ APP_PID_FILE="$APP_PID_DIR/$APP_NAME.pid"
APP_OUT_FILE="$APP_LOG_DIR/$APP_NAME.out"
APP_ERR_FILE="$APP_LOG_DIR/$APP_NAME.err"
-# Java command
-JAVA_CMD=java
-
# The start wait time
APP_START_WAIT_TIME=2
# The kill wait time limit
APP_KILL_WAIT_TIME=10
+# Setup the common environment
+. $APP_BIN_DIR/knox-env.sh
+
function main {
case "$1" in
setup)
@@ -101,7 +101,7 @@ function main {
function setupEnv {
checkEnv
- $JAVA_CMD -jar $APP_JAR -persist-master -nostart
+ $JAVA -jar $APP_JAR -persist-master -nostart
return 0
}
@@ -118,7 +118,7 @@ function appStart {
rm -f $APP_PID_FILE
- nohup $JAVA_CMD $APP_MEM_OPTS $APP_DBG_OPTS $APP_LOG_OPTS -jar $APP_JAR >>$APP_OUT_FILE 2>>$APP_ERR_FILE & printf $!>$APP_PID_FILE || exit 1
+ nohup $JAVA $APP_MEM_OPTS $APP_DBG_OPTS $APP_LOG_OPTS -jar $APP_JAR >>$APP_OUT_FILE 2>>$APP_ERR_FILE & printf $!>$APP_PID_FILE || exit 1
getPID
for ((i=0; i<APP_START_WAIT_TIME*10; i++)); do
@@ -286,7 +286,7 @@ function deleteLogFiles {
}
function printHelp {
- $JAVA_CMD -jar $APP_JAR -help
+ $JAVA -jar $APP_JAR -help
return 0
}
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/de67dcb8/gateway-release/home/bin/knox-env.sh
----------------------------------------------------------------------
diff --git a/gateway-release/home/bin/knox-env.sh b/gateway-release/home/bin/knox-env.sh
new file mode 100644
index 0000000..c33ae00
--- /dev/null
+++ b/gateway-release/home/bin/knox-env.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+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() {
+ # Check to make sure any existing JAVA var is valid.
+ if [ "$JAVA" != "" ]; then
+ if [ ! -x "$JAVA" ]; then
+ JAVA=""
+ fi
+ fi
+
+ # Try to find java on PATH.
+ if [ "$JAVA" == "" ]; then
+ JAVA=`which java 2>/dev/null`
+ if [ ! -x "$JAVA" ]; then
+ JAVA=""
+ fi
+ fi
+
+ # Try to use JAVA_HOME to find java.
+ if [ "$JAVA" == "" ]; then
+ if [ "$JAVA_HOME" != "" ]; then
+ JAVA=$JAVA_HOME/bin/java
+ if [ ! -x "$JAVA" ]; then
+ JAVA=""
+ fi
+ fi
+ fi
+
+ # Use the search patterns to find java.
+ if [ "$JAVA" == "" ]; then
+ for pattern in "${JAVA_VERSION_PATTERNS[@]}"; do
+ JAVA=( $(find /usr -executable -name java -print 2> /dev/null | grep "$pattern" | head -n 1 ) )
+ if [ -x "$JAVA" ]; then
+ break
+ else
+ JAVA=""
+ fi
+ done
+ fi
+}
+
+findJava
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/de67dcb8/gateway-release/home/bin/knoxcli.sh
----------------------------------------------------------------------
diff --git a/gateway-release/home/bin/knoxcli.sh b/gateway-release/home/bin/knoxcli.sh
index cdb006c..93f55ca 100755
--- a/gateway-release/home/bin/knoxcli.sh
+++ b/gateway-release/home/bin/knoxcli.sh
@@ -51,20 +51,20 @@ APP_DBG_OPTS=""
APP_OUT_FILE="$APP_LOG_DIR/$APP_NAME.out"
APP_ERR_FILE="$APP_LOG_DIR/$APP_NAME.err"
-# Java command
-JAVA_CMD=java
+# Setup the common environment
+. $APP_BIN_DIR/knox-env.sh
function main {
printf "Starting $APP_LABEL \n"
#printf "$@"
- exec $JAVA_CMD $APP_MEM_OPTS $APP_DBG_OPTS $APP_LOG_OPTS -jar $APP_JAR "$@" || exit 1
+ exec $JAVA $APP_MEM_OPTS $APP_DBG_OPTS $APP_LOG_OPTS -jar $APP_JAR "$@" || exit 1
return 0
}
function printHelp {
- $JAVA_CMD -jar $APP_JAR -help
+ $JAVA -jar $APP_JAR -help
return 0
}
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/de67dcb8/gateway-release/home/bin/ldap.sh
----------------------------------------------------------------------
diff --git a/gateway-release/home/bin/ldap.sh b/gateway-release/home/bin/ldap.sh
index 51a615f..21aa4a7 100755
--- a/gateway-release/home/bin/ldap.sh
+++ b/gateway-release/home/bin/ldap.sh
@@ -64,15 +64,15 @@ APP_PID_FILE="$APP_PID_DIR/$APP_NAME.pid"
APP_OUT_FILE="$APP_LOG_DIR/$APP_NAME.out"
APP_ERR_FILE="$APP_LOG_DIR/$APP_NAME.err"
-# Java command
-JAVA_CMD=java
-
# The start wait time
APP_START_WAIT_TIME=2
# The kill wait time limit
APP_KILL_WAIT_TIME=10
+# Setup the common environment
+. $APP_BIN_DIR/knox-env.sh
+
function main {
case "$1" in
start)
@@ -106,7 +106,7 @@ function appStart {
rm -f $APP_PID_FILE
- nohup $JAVA_CMD $APP_MEM_OPTS $APP_DBG_OPTS $APP_LOG_OPTS -jar $APP_JAR $APP_CONF_DIR >>$APP_OUT_FILE 2>>$APP_ERR_FILE & printf $!>$APP_PID_FILE || exit 1
+ nohup $JAVA $APP_MEM_OPTS $APP_DBG_OPTS $APP_LOG_OPTS -jar $APP_JAR $APP_CONF_DIR >>$APP_OUT_FILE 2>>$APP_ERR_FILE & printf $!>$APP_PID_FILE || exit 1
getPID
for ((i=0; i<APP_START_WAIT_TIME*10; i++)); do