Fixed run.sh to autodetect JAVA_HOME on Mac OS X 71/971/2
authorEd Warnicke <eaw@cisco.com>
Thu, 22 Aug 2013 19:24:39 +0000 (14:24 -0500)
committerEd Warnicke <eaw@cisco.com>
Thu, 22 Aug 2013 22:56:55 +0000 (17:56 -0500)
Change-Id: I3043d19a90f90258883a870d65acd8c26698e3e1
Signed-off-by: Ed Warnicke <eaw@cisco.com>
opendaylight/distribution/opendaylight/src/main/resources/run.sh

index 313b3b2..2587a5d 100755 (executable)
@@ -1,9 +1,5 @@
 #!/bin/bash
 
-[[ -z ${JAVA_HOME} ]] && echo "Need to set JAVA_HOME environment variable" && exit -1;
-[[ ! -x ${JAVA_HOME}/bin/java ]] && echo "Cannot find an executable \
-JVM at path ${JAVA_HOME}/bin/java check your JAVA_HOME" && exit -1;
-
 platform='unknown'
 unamestr=`uname`
 if [[ "$unamestr" == 'Linux' ]]; then
@@ -32,8 +28,15 @@ elif [[ $platform == 'osx' ]]; then
    PHYS_DIR=`pwd -P`
    RESULT=$PHYS_DIR/$TARGET_FILE
    fullpath=$RESULT
+
+   [[ -z ${JAVA_HOME} ]] && [[ -x "/usr/libexec/java_home" ]] && export JAVA_HOME=`/usr/libexec/java_home -v 1.7`;
+
 fi
 
+[[ -z ${JAVA_HOME} ]] && echo "Need to set JAVA_HOME environment variable" && exit -1;
+[[ ! -x ${JAVA_HOME}/bin/java ]] && echo "Cannot find an executable \
+JVM at path ${JAVA_HOME}/bin/java check your JAVA_HOME" && exit -1;
+
 basedir=`dirname ${fullpath}`
 
 function usage {