From 69287099bab9640465cb18ef4006252d05a33e5d Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Fri, 28 Sep 2007 19:50:40 +0000
Subject: [PATCH] Fix for issue 2035 (Use OpenDS specific environment variables to determine the JVM to be used.)

---
 opends/resource/setup |   79 ++++++++++++++++++++++-----------------
 1 files changed, 45 insertions(+), 34 deletions(-)

diff --git a/opends/resource/setup b/opends/resource/setup
index 2210297..1109c86 100755
--- a/opends/resource/setup
+++ b/opends/resource/setup
@@ -26,30 +26,55 @@
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 
 
-# See if JAVA_HOME is set.  If not, then see if there is a java executable in
-# the path and try to figure it out.
-if test -z "${JAVA_BIN}"
+# Capture the current working directory so that we can change to it later.
+# Then capture the location of this script and the Directory Server instance
+# root so that we can use them to create appropriate paths.
+WORKING_DIR=`pwd`
+
+cd `dirname "${0}"`
+SCRIPT_DIR=`pwd`
+
+INSTANCE_ROOT=${SCRIPT_DIR}
+export INSTANCE_ROOT
+
+cd "${WORKING_DIR}"
+
+# See if the environment variables are set.  If not, then see if there is a java
+# executable in the path and try to figure it out.
+if test -z "${OPENDS_JAVA_BIN}"
 then
-  if test -z "${JAVA_HOME}"
+  if test -z "${OPENDS_JAVA_HOME}"
   then
     if test -f "${INSTANCE_ROOT}/lib/set-java-home"
     then
-      . "${INSTANCE_ROOT}/bin/set-java-home"
-      JAVA_BIN="${JAVA_HOME}/bin/java"
-      export JAVA_BIN
+      . "${INSTANCE_ROOT}/lib/set-java-home"
+      OPENDS_JAVA_BIN="${OPENDS_JAVA_HOME}/bin/java"
+      export OPENDS_JAVA_BIN
     else
-      JAVA_BIN=`which java 2> /dev/null`
-      if test ${?} -eq 0
+      if test -z "${JAVA_BIN}"
       then
-        export JAVA_BIN
+        if test -z "${JAVA_HOME}"
+        then
+          OPENDS_JAVA_BIN=`which java 2> /dev/null`
+          if test ${?} -eq 0
+          then
+            export OPENDS_JAVA_BIN
+          else
+            echo "Please set OPENDS_JAVA_HOME to the root of a Java 5 (or later) installation."
+            exit 1
+          fi
+        else
+          OPENDS_JAVA_BIN="${JAVA_HOME}/bin/java"
+          export OPENDS_JAVA_BIN
+        fi
       else
-        echo "Please set JAVA_HOME to the root of a Java 5  (or later) installation."
-        exit 1
+        OPENDS_JAVA_BIN="${JAVA_BIN}"
+        export OPENDS_JAVA_BIN
       fi
     fi
   else
-    JAVA_BIN="${JAVA_HOME}/bin/java"
-    export JAVA_BIN
+    OPENDS_JAVA_BIN="${OPENDS_JAVA_HOME}/bin/java"
+    export OPENDS_JAVA_BIN
   fi
 fi
 
@@ -67,20 +92,6 @@
        LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_34
 
 
-# Capture the current working directory so that we can change to it later.
-# Then capture the location of this script and the Directory Server instance
-# root so that we can use them to create appropriate paths.
-WORKING_DIR=`pwd`
-
-cd `dirname "${0}"`
-SCRIPT_DIR=`pwd`
-
-INSTANCE_ROOT=${SCRIPT_DIR}
-export INSTANCE_ROOT
-
-cd "${WORKING_DIR}"
-
-
 # Configure the appropriate CLASSPATH.
 CLASSPATH=${INSTANCE_ROOT}/classes
 for JAR in ${INSTANCE_ROOT}/lib/*.jar
@@ -93,32 +104,32 @@
 # Determine whether the detected Java environment is acceptable for use.
 if test -z "${JAVA_ARGS}"
 then
-  "${JAVA_BIN}" -client org.opends.server.tools.InstallDS -t 2> /dev/null
+  "${OPENDS_JAVA_BIN}" -client org.opends.server.tools.InstallDS -t 2> /dev/null
   if test ${?} -eq 0
   then
     JAVA_ARGS="-client"
   else
-    "${JAVA_BIN}" org.opends.server.tools.InstallDS -t 2> /dev/null
+    "${OPENDS_JAVA_BIN}" org.opends.server.tools.InstallDS -t 2> /dev/null
     if test ${?} -ne 0
     then
       echo "ERROR:  The detected Java version could not be used.  Please set "
-      echo "        JAVA_HOME to the root of a Java 5 (or later) installation."
+      echo "        OPENDS_JAVA_HOME to the root of a Java 5 (or later) installation."
       exit 1
     fi
   fi
 else
-  "${JAVA_BIN}" ${JAVA_ARGS} org.opends.server.tools.InstallDS -t 2> /dev/null
+  "${OPENDS_JAVA_BIN}" ${JAVA_ARGS} org.opends.server.tools.InstallDS -t 2> /dev/null
   if test ${?} -ne 0
   then
     echo "ERROR:  The detected Java version could not be used.  Please set "
-    echo "        JAVA_HOME to the root of a Java 5 (or later) installation."
+    echo "        OPENDS_JAVA_HOME to the root of a Java 5 (or later) installation."
     exit 1
   fi
 fi
 
 
 # Launch the setup process.
-"${JAVA_BIN}" -Dorg.opends.server.scriptName=setup org.opends.quicksetup.installer.SetupLauncher "${@}"
+"${OPENDS_JAVA_BIN}" -Dorg.opends.server.scriptName=setup org.opends.quicksetup.installer.SetupLauncher "${@}"
 
 # return part
 RETURN_CODE=$?

--
Gitblit v1.10.0