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/bin/stop-ds |   50 +++++++++++++++++++++++++++++++-------------------
 1 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/opends/resource/bin/stop-ds b/opends/resource/bin/stop-ds
index 02ee4df..b16faa8 100755
--- a/opends/resource/bin/stop-ds
+++ b/opends/resource/bin/stop-ds
@@ -50,30 +50,42 @@
 cd "${WORKING_DIR}"
 
 
-# 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}"
+# 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}/lib/set-java-home"
-      JAVA_BIN="${JAVA_HOME}/bin/java"
-      export JAVA_BIN
+      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.0 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
 
@@ -107,7 +119,7 @@
 # Test that the provided JDK is 1.5 compatible.
 if test -z "${JAVA_ARGS}"
 then
-  "${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 "
@@ -115,16 +127,16 @@
     exit 1
   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 with the specified"
-    echo "Java arguments.  Please set  JAVA_HOME to the root of a Java 5.0 installation."
+    echo "Java arguments.  Please set  OPENDS_JAVA_HOME to the root of a Java 5.0 installation."
     exit 1
   fi
 fi
 
-"${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
+"${OPENDS_JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
   org.opends.server.tools.StopDS --checkStoppability "${@}"
 EC=${?}
 
@@ -189,7 +201,7 @@
     EXIT_CODE=${?}
     if test ${EXIT_CODE} -eq 0
     then
-      "${JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
+      "${OPENDS_JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
         --targetFile "${INSTANCE_ROOT}/logs/server.pid" \
         --logFile "${INSTANCE_ROOT}/logs/errors"
       EXIT_CODE=${?}
@@ -244,5 +256,5 @@
 fi
 
 # If we've gotten here, then we should try to stop the server over LDAP.
-"${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
+"${OPENDS_JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
   org.opends.server.tools.StopDS "${@}"

--
Gitblit v1.10.0