cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kis...@apache.org
Subject git commit: updated refs/heads/master to c468228
Date Wed, 25 Jun 2014 11:54:35 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 75c9a20c7 -> c468228fe


CLOUDSTACK-6926: removed hard coded jdk dirs and setting java home using readlink and dirname


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

Branch: refs/heads/master
Commit: c468228fe807c621decc5919dadae9bcbb38c753
Parents: 75c9a20
Author: Rajani Karuturi <rajanikaruturi@gmail.com>
Authored: Wed Jun 18 15:36:32 2014 +0530
Committer: Kishan Kavala <kishan@cloud.com>
Committed: Wed Jun 25 17:23:42 2014 +0530

----------------------------------------------------------------------
 packaging/centos63/cloud-usage.rc | 32 ++++++++++++++++++++++++--------
 packaging/debian/init/cloud-usage | 32 ++++++++++++++++++++++++--------
 2 files changed, 48 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c468228f/packaging/centos63/cloud-usage.rc
----------------------------------------------------------------------
diff --git a/packaging/centos63/cloud-usage.rc b/packaging/centos63/cloud-usage.rc
index 6170379..8434e4d 100755
--- a/packaging/centos63/cloud-usage.rc
+++ b/packaging/centos63/cloud-usage.rc
@@ -46,15 +46,31 @@ USER=cloud
 unset OPTIONS
 [ -r /etc/sysconfig/default/"$SHORTNAME" ] && source /etc/sysconfig/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 /usr/lib/jvm/java-7-openjdk-i386 /usr/lib/jvm/java-7-openjdk-amd64
/usr/lib/jvm/java-7-sun /usr/lib/jvm/jre-1.7.0 /usr/lib/j2sdk1.5-sun /usr/lib/jre-openjdk"
+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
+
+  # didnt find java home. exiting with error
+  exit 1
+}
 
-for jdir in $JDK_DIRS; do
-    if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
-        JAVA_HOME="$jdir"
-    fi
-done
-export JAVA_HOME
+setJavaHome
 
 SCP=""
 DCP=""

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c468228f/packaging/debian/init/cloud-usage
----------------------------------------------------------------------
diff --git a/packaging/debian/init/cloud-usage b/packaging/debian/init/cloud-usage
index 1cc75cc..a12dc70 100755
--- a/packaging/debian/init/cloud-usage
+++ b/packaging/debian/init/cloud-usage
@@ -42,15 +42,31 @@ 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-6-openjdk
/usr/lib/jvm/java-6-openjdk-i386 /usr/lib/jvm/java-6-openjdk-amd64 /usr/lib/jvm/java-6-sun"
+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
+
+  # didnt find java home. exiting with error
+  exit 1
+}
 
-for jdir in $JDK_DIRS; do
-    if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
-        JAVA_HOME="$jdir"
-    fi
-done
-export JAVA_HOME
+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