From bbadcb75d4629441e73ea04782ae2c5decf64fe3 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Mon, 17 Dec 2007 10:43:53 +0000
Subject: [PATCH] 2730: New - The setup command should perform some basic memory tuning Note: this issue is not fully covered by the proposed modifications but all that is missing in order to fix it is to figure out which are the default memory values that we want to propose in the setup.

---
 opends/resource/upgrade |  104 ++++++++++++++-------------------------------------
 1 files changed, 29 insertions(+), 75 deletions(-)

diff --git a/opends/resource/upgrade b/opends/resource/upgrade
index fc3333c..c615a19 100644
--- a/opends/resource/upgrade
+++ b/opends/resource/upgrade
@@ -25,19 +25,6 @@
 #
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 
-# Explicitly set the PATH, LD_LIBRARY_PATH, LD_PRELOAD, and other important
-# system environment variables for security and compatibility reasons.
-PATH=/bin:/usr/bin
-LD_LIBRARY_PATH=
-LD_LIBRARY_PATH_32=
-LD_LIBRARY_PATH_64=
-LD_PRELOAD=
-LD_PRELOAD_32=
-LD_PRELOAD_64=
-export PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 \
-       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.
@@ -49,47 +36,30 @@
 INSTANCE_ROOT=${SCRIPT_DIR}
 export INSTANCE_ROOT
 
+SCRIPT_NAME=upgrade
+export SCRIPT_NAME
+
 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}"
+# Set java home
+SCRIPT_UTIL_CMD=set-java-home-and-args
+export SCRIPT_UTIL_CMD
+.  "${INSTANCE_ROOT}/lib/_script-util.sh"
+RETURN_CODE=$?
+if test ${RETURN_CODE} -ne 0
 then
-  if test -z "${OPENDS_JAVA_HOME}"
-  then
-    if test -f "${INSTANCE_ROOT}/lib/set-java-home"
-    then
-      . "${INSTANCE_ROOT}/lib/set-java-home"
-      OPENDS_JAVA_BIN="${OPENDS_JAVA_HOME}/bin/java"
-      export OPENDS_JAVA_BIN
-    else
-      if test -z "${JAVA_BIN}"
-      then
-        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
-        OPENDS_JAVA_BIN="${JAVA_BIN}"
-        export OPENDS_JAVA_BIN
-      fi
-    fi
-  else
-    OPENDS_JAVA_BIN="${OPENDS_JAVA_HOME}/bin/java"
-    export OPENDS_JAVA_BIN
-  fi
+  exit ${RETURN_CODE}
 fi
 
+# Set environment variables
+SCRIPT_UTIL_CMD=set-environment-vars
+export SCRIPT_UTIL_CMD
+.  "${INSTANCE_ROOT}/lib/_script-util.sh"
+RETURN_CODE=$?
+if test ${RETURN_CODE} -ne 0
+then
+  exit ${RETURN_CODE}
+fi
 
 # Configure the appropriate CLASSPATH to test.
 for JAR in ${INSTANCE_ROOT}/tmp/upgrade/lib/*.jar
@@ -103,30 +73,14 @@
 done
 export CLASSPATH
 
-# Determine whether the detected Java environment is acceptable for use.
-if test -z "${JAVA_ARGS}"
+# Test the java installation
+SCRIPT_UTIL_CMD=test-java
+export SCRIPT_UTIL_CMD
+.  "${INSTANCE_ROOT}/lib/_script-util.sh"
+RETURN_CODE=$?
+if test ${RETURN_CODE} -ne 0
 then
-  "${OPENDS_JAVA_BIN}" -client org.opends.server.tools.InstallDS -t 2> /dev/null
-  if test ${?} -eq 0
-  then
-    JAVA_ARGS="-client"
-  else
-    "${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 "        OPENDS_JAVA_HOME to the root of a Java 5 (or later) installation."
-      exit 1
-    fi
-  fi
-else
-  "${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 "        OPENDS_JAVA_HOME to the root of a Java 5.0 installation."
-    exit 1
-  fi
+  exit ${RETURN_CODE}
 fi
 
 if [ -r "${INSTANCE_ROOT}/tmp/upgrade" ]
@@ -151,7 +105,7 @@
 # operation is a reversion.  An exit code of 50 means that the usage
 # statement was printed and there is nothing else to do
 
-"${OPENDS_JAVA_BIN}" org.opends.quicksetup.upgrader.BuildExtractor "${@}"
+"${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} org.opends.quicksetup.upgrader.BuildExtractor "${@}"
 RETURN_CODE=$?
 if test ${RETURN_CODE} -eq 99
 then
@@ -164,7 +118,7 @@
     CLASSPATH=${JAR}:${CLASSPATH}
   done
   # Launch the upgrade process.
-  "${OPENDS_JAVA_BIN}" org.opends.quicksetup.upgrader.UpgradeLauncher "${@}"
+  "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} org.opends.quicksetup.upgrader.UpgradeLauncher "${@}"
 elif test ${RETURN_CODE} -eq 98
 then
   # Copy jars to a temporary place from which to run the reverter
@@ -182,7 +136,7 @@
       CLASSPATH=${JAR}:${CLASSPATH}
     done
     # Launch the upgrade process.
-    "${OPENDS_JAVA_BIN}" org.opends.quicksetup.upgrader.ReversionLauncher "${@}"
+    "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} org.opends.quicksetup.upgrader.ReversionLauncher "${@}"
   fi
 elif test ${RETURN_CODE} -eq 50
 then

--
Gitblit v1.10.0