cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject git commit: updated refs/heads/4.4 to e77da80
Date Fri, 08 Aug 2014 12:47:14 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.4 96d6a2a03 -> e77da80e0


CLOUDSTACK-6360: pick setJavaHome from 4.3 and master for 4.4 branch

A JAVA_HOME finder method was implemented by Rajani and got into master and 4.3
but not 4.4: https://reviews.apache.org/r/22721/

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


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

Branch: refs/heads/4.4
Commit: e77da80e01b0774951e5c2ab1b23539af002b8b4
Parents: 96d6a2a
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Fri Aug 8 14:45:47 2014 +0200
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Fri Aug 8 14:45:47 2014 +0200

----------------------------------------------------------------------
 packaging/debian/init/cloud-usage | 41 ++++++++++++++++++++++++++++------
 1 file changed, 34 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e77da80e/packaging/debian/init/cloud-usage
----------------------------------------------------------------------
diff --git a/packaging/debian/init/cloud-usage b/packaging/debian/init/cloud-usage
index b4cb42b..06b1142 100755
--- a/packaging/debian/init/cloud-usage
+++ b/packaging/debian/init/cloud-usage
@@ -42,15 +42,42 @@ DAEMON="/usr/bin/jsvc"
 unset OPTIONS
 [ -r /etc/default/"$SHORTNAME" ] && source /etc/default/"$SHORTNAME"
 
-# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not defined in $DEFAULT)
-JDK_DIRS="/usr/lib/jvm/java-7-openjdk-amd64 /usr/lib/jvm/java-7-openjdk-i386 /usr/lib/jvm/java-7-oracle
/usr/lib/jvm/java-7-openjdk /usr/lib/jvm/java-7-sun"
-
-for jdir in $JDK_DIRS; do
+setJavaHome() {
+  # use $JAVA_HOME if defined
+  if [ -n "$JAVA_HOME" ] ; then
+    return
+  fi
+
+  # try javac first
+  java=$(which javac 2>/dev/null || :)
+
+  # try java if javac is not found
+  if [ -z "$java" ] ; then
+    java=$(which java 2>/dev/null || :)
+  fi
+
+  if [ -n "$java" ] ; then
+    JAVA_HOME=$(dirname $(dirname $(readlink -e $java)))
+    export JAVA_HOME
+    return
+  fi
+
+  # If everything has failed, try hardcoded paths
+  # The first existing directory is used for JAVA_HOME (if JAVA_HOME is not defined in $DEFAULT)
+  JDK_DIRS="/usr/lib/jvm/java-7-openjdk-amd64 /usr/lib/jvm/java-7-openjdk-i386 /usr/lib/jvm/java-7-oracle
/usr/lib/jvm/java-7-openjdk /usr/lib/jvm/java-7-sun"
+  for jdir in $JDK_DIRS; do
     if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
-        JAVA_HOME="$jdir"
+      JAVA_HOME="$jdir"
+      export JAVA_HOME
+      return
     fi
-done
-export JAVA_HOME
+  done
+
+  # didnt find java home. exiting with error
+  exit 1
+}
+
+setJavaHome
 
 UCP=`ls /usr/share/cloudstack-usage/lib/*.jar | tr '\n' ':' | sed s'/.$//'`
 PCP=`ls /usr/share/cloudstack-usage/plugins/*.jar 2>/dev/null | tr '\n' ':' | sed s'/.$//'`


Mime
View raw message