karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject karaf git commit: [KARAF-4564] [KARAF-4852] [KARAF-4865] Improve the main karaf script * use /bin/sh * do not rely on readlink, but use 'ls -l' * check exit code when changing directory * verify ulimit availability * use 'command -v' instead of 'typ
Date Mon, 03 Apr 2017 14:59:37 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-4.0.x a6eb281b3 -> f7fad515f


[KARAF-4564] [KARAF-4852] [KARAF-4865] Improve the main karaf script
 * use /bin/sh
 * do not rely on readlink, but use 'ls -l'
 * check exit code when changing directory
 * verify ulimit availability
 * use 'command -v' instead of 'type'
 * support spaces in the JAVA path
 * do not use {} expansion for file names
 * fix endorsed/ext dirs on cygwin/mingw


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/f7fad515
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/f7fad515
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/f7fad515

Branch: refs/heads/karaf-4.0.x
Commit: f7fad515f7f64ca43923000d49b6b4a46974722b
Parents: a6eb281
Author: Guillaume Nodet <gnodet@apache.org>
Authored: Wed Dec 7 00:06:39 2016 +0100
Committer: Jean-Baptiste Onofré <jbonofre@apache.org>
Committed: Mon Apr 3 16:40:11 2017 +0200

----------------------------------------------------------------------
 .../base/src/main/resources/resources/bin/karaf | 117 ++++++++++---------
 1 file changed, 65 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/f7fad515/assemblies/features/base/src/main/resources/resources/bin/karaf
----------------------------------------------------------------------
diff --git a/assemblies/features/base/src/main/resources/resources/bin/karaf b/assemblies/features/base/src/main/resources/resources/bin/karaf
index 57c4d37..a86956b 100755
--- a/assemblies/features/base/src/main/resources/resources/bin/karaf
+++ b/assemblies/features/base/src/main/resources/resources/bin/karaf
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 #    Licensed to the Apache Software Foundation (ASF) under one or more
 #    contributor license agreements.  See the NOTICE file distributed with
@@ -17,32 +17,17 @@
 #
 
 realpath() {
-  READLINK_EXISTS=$(command -v readlink &> /dev/null)
-  if [ -z $READLINK_EXISTS ]; then
-    OURPWD=${PWD}
-    cd "$(dirname "${1}")" || exit 2
+  OURPWD=${PWD}
+  cd "$(dirname "${1}")" || exit 2
+  LINK=$(ls -l "$(basename "${1}")" | awk -F"-> " '{print $2}')
+  while [ "${LINK}" ]; do
+	  echo "link: ${LINK}" >&2
+    cd "$(dirname "${LINK}")" || exit 2
     LINK=$(ls -l "$(basename "${1}")" | awk -F"-> " '{print $2}')
-    while [ "${LINK}" ]; do
-        echo "link: ${LINK}" >&2
-        cd "$(dirname "${LINK}")" || exit 2
-        LINK=$(ls -l "$(basename "${1}")" | awk -F"-> " '{print $2}')
-    done
-    REALPATH="${PWD}/$(basename "${1}")"
-    cd "${OURPWD}" || exit 2
-    echo "${REALPATH}"
-  else
-    OURPWD=${PWD}
-    cd "$(dirname "${1}")" || exit 2
-    LINK=$(readlink "$(basename "${1}")")
-    while [ "${LINK}" ]; do
-	    echo "link: ${LINK}" >&2
-        cd "$(dirname "${LINK}")" || exit 2
-        LINK=$(readlink "$(basename "${1}")")
-    done
-    REALPATH="${PWD}/$(basename "${1}")"
-    cd "${OURPWD}" || exit 2
-    echo "${REALPATH}"
-  fi
+  done
+  REALPATH="${PWD}/$(basename "${1}")"
+  cd "${OURPWD}" || exit 2
+  echo "${REALPATH}"
 }
 
 REALNAME=$(realpath "$0")
@@ -128,8 +113,8 @@ unlimitFD() {
     fi
 
     # Increase the maximum file descriptors if we can
-    if [ "${os400}" = "false" ] && [ "${cygwin}" = "false" ]; then
-        if [ "${MAX_FD}" = "maximum" -o "${MAX_FD}" = "max" ]; then
+    if [ "x$(command -v ulimit)" != "x" ] && [ "${os400}" = "false" ] ; then
+        if [ "${MAX_FD}" = "maximum" ] || [ "${MAX_FD}" = "max" ]; then
             MAX_FD_LIMIT=$(ulimit -H -n)
             if [ $? -eq 0 ]; then
                 # use the system max
@@ -152,7 +137,7 @@ locateHome() {
         # In POSIX shells, CDPATH may cause cd to write to stdout
         (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
         # KARAF_HOME is not provided, fall back to default
-        KARAF_HOME=$(cd "${DIRNAME}/.."; pwd)
+        KARAF_HOME=$(cd "${DIRNAME}/.." || exit 2; pwd)
     fi
 
     if [ ! -d "${KARAF_HOME}" ]; then
@@ -243,8 +228,7 @@ locateJava() {
             JAVA="${JAVA_HOME}/bin/java"
         else
             warn "JAVA_HOME not set; results may vary"
-            JAVA=$(type java)
-            JAVA=$(expr "${JAVA}" : '.* \(/.*\)$')
+            JAVA=$(command -v java)
             if [ "x${JAVA}" = "x" ]; then
                 die "java command not found"
             fi
@@ -272,8 +256,10 @@ detectJVM() {
 
 checkJvmVersion() {
     # echo "$(${JAVA} -version)"
-    VERSION=$(${JAVA} -version 2>&1 | egrep '"([0-9].[0-9]\..*[0-9]).*"' | awk '{print
substr($3,2,length($3)-2)}' | awk '{print substr($1, 3, 3)}' | sed -e 's;\.;;g')
-    # echo ${VERSION}
+    VERSION=$("${JAVA}" -version 2>&1 | egrep '"([0-9].[0-9]\..*[0-9]).*"' | awk '{print
substr($3,2,length($3)-2)}' | awk '{print substr($1, 3, 3)}' | sed -e 's;\.;;g')
+    if [ "x${VERSION}" = "x" ]; then
+       VERSION=90
+    fi
     if [ "${VERSION}" -lt "60" ]; then
         echo "JVM must be greater than 1.6"
         exit 1;
@@ -318,7 +304,10 @@ setupDefaults() {
     #Set the JVM_VENDOR specific JVM flags
     if [ "${JVM_VENDOR}" = "SUN" ]; then
         # permgen was removed in Java 8
-        VERSION=$(${JAVA} -version 2>&1 | egrep '"([0-9].[0-9]\..*[0-9]).*"' | awk
'{print substr($3,2,length($3)-2)}' | awk '{print substr($1, 3, 3)}' | sed -e 's;\.;;g')
+        VERSION=$("${JAVA}" -version 2>&1 | egrep '"([0-9].[0-9]\..*[0-9]).*"' | awk
'{print substr($3,2,length($3)-2)}' | awk '{print substr($1, 3, 3)}' | sed -e 's;\.;;g')
+        if [ "x${VERSION}" = "x" ]; then
+            VERSION=90
+        fi
         if [ "${VERSION}" -lt "80" ]; then
             # Check some easily accessible MIN/MAX params for JVM mem usage
             if [ "x${JAVA_PERM_MEM}" != "x" ]; then
@@ -429,7 +418,7 @@ run() {
     while [ "${1}" != "" ]; do
         case ${1} in
             'clean')
-                rm -rf "${KARAF_DATA:?}"/{.[^.],.??*,*}
+                rm -rf "${KARAF_DATA:?}"
                 shift
                 ;;
             'debug')
@@ -488,7 +477,7 @@ run() {
         JAVA_ENDORSED_DIRS=$(cygpath --path --windows "${JAVA_ENDORSED_DIRS}")
         JAVA_EXT_DIRS=$(cygpath --path --windows "${JAVA_EXT_DIRS}")
     fi
-    cd "${KARAF_BASE}"
+    cd "${KARAF_BASE}" || exit 2
 
     if [ -z "${KARAF_EXEC}" ]; then
         KARAF_EXEC=""
@@ -510,22 +499,46 @@ run() {
         fi
 
         if [ "${ROOT_INSTANCE_RUNNING}" = "false" ] || [ "${CHECK_ROOT_INSTANCE_RUNNING}"
= "false" ] ; then
-            ${KARAF_EXEC} "${JAVA}" ${JAVA_OPTS} \
-                -Djava.endorsed.dirs="${JAVA_ENDORSED_DIRS}" \
-                -Djava.ext.dirs="${JAVA_EXT_DIRS}" \
-                -Dkaraf.instances="${KARAF_HOME}/instances" \
-                -Dkaraf.home="${KARAF_HOME}" \
-                -Dkaraf.base="${KARAF_BASE}" \
-                -Dkaraf.data="${KARAF_DATA}" \
-                -Dkaraf.etc="${KARAF_ETC}" \
-                -Dkaraf.restart.jvm.supported=true \
-                -Djava.io.tmpdir="${KARAF_DATA}/tmp" \
-                -Djava.util.logging.config.file="${KARAF_BASE}/etc/java.util.logging.properties"
\
-                ${KARAF_SYSTEM_OPTS} \
-                ${KARAF_OPTS} \
-                ${OPTS} \
-                -classpath "${CLASSPATH}" \
-                ${MAIN} "$@"
+            if [ "${VERSION}" -gt "80" ]; then
+                ${KARAF_EXEC} "${JAVA}" ${JAVA_OPTS} \
+                    --add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED \
+                    --add-exports=java.base/sun.net.www.protocol.https=ALL-UNNAMED \
+                    --add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED \
+                    --add-exports=java.xml.bind/com.sun.xml.internal.bind.v2.runtime=ALL-UNNAMED
\
+                    --add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED \
+                    --add-exports=jdk.naming.rmi/com.sun.jndi.url.rmi=ALL-UNNAMED \
+                    --add-modules java.annotations.common,java.corba,java.transaction,java.xml.bind,java.xml.ws
\
+                    -Dkaraf.instances="${KARAF_HOME}/instances" \
+                    -Dkaraf.home="${KARAF_HOME}" \
+                    -Dkaraf.base="${KARAF_BASE}" \
+                    -Dkaraf.data="${KARAF_DATA}" \
+                    -Dkaraf.etc="${KARAF_ETC}" \
+                    -Dkaraf.restart.jvm.supported=true \
+                    -Djava.io.tmpdir="${KARAF_DATA}/tmp" \
+                    -Djava.util.logging.config.file="${KARAF_BASE}/etc/java.util.logging.properties"
\
+                    ${KARAF_SYSTEM_OPTS} \
+                    ${KARAF_OPTS} \
+                    ${OPTS} \
+                    -classpath "${CLASSPATH}" \
+                    ${MAIN} "$@"
+            else
+                ${KARAF_EXEC} "${JAVA}" ${JAVA_OPTS} \
+                    -Djava.endorsed.dirs="${JAVA_ENDORSED_DIRS}" \
+                    -Djava.ext.dirs="${JAVA_EXT_DIRS}" \
+                    -Dkaraf.instances="${KARAF_HOME}/instances" \
+                    -Dkaraf.home="${KARAF_HOME}" \
+                    -Dkaraf.base="${KARAF_BASE}" \
+                    -Dkaraf.data="${KARAF_DATA}" \
+                    -Dkaraf.etc="${KARAF_ETC}" \
+                    -Dkaraf.restart.jvm.supported=true \
+                    -Djava.io.tmpdir="${KARAF_DATA}/tmp" \
+                    -Djava.util.logging.config.file="${KARAF_BASE}/etc/java.util.logging.properties"
\
+                    ${KARAF_SYSTEM_OPTS} \
+                    ${KARAF_OPTS} \
+                    ${OPTS} \
+                    -classpath "${CLASSPATH}" \
+                    ${MAIN} "$@"
+            fi
         else
             die "There is a Root instance already running with name ${ROOT_INSTANCE_NAME}
and pid ${ROOT_INSTANCE_PID}"
         fi


Mime
View raw message