From f3c05f3d25c27eb4e7b19ddb562396591f423b84 Mon Sep 17 00:00:00 2001
From: chebrard <chebrard@localhost>
Date: Tue, 04 Nov 2008 19:58:07 +0000
Subject: [PATCH] Fix 3548: perf regression in OpenDS between rev 4539 and rev 4548

---
 opendj-sdk/opends/resource/bin/_client-script.sh |    5 ++
 opendj-sdk/opends/resource/bin/_script-util.sh   |   58 ++++++++++++++++------------
 opendj-sdk/opends/resource/bin/status-panel      |    3 +
 opendj-sdk/opends/resource/bin/control-panel     |    3 +
 opendj-sdk/opends/resource/bin/_mixed-script.sh  |    4 ++
 opendj-sdk/opends/resource/bin/dsjavaproperties  |    3 +
 6 files changed, 51 insertions(+), 25 deletions(-)

diff --git a/opendj-sdk/opends/resource/bin/_client-script.sh b/opendj-sdk/opends/resource/bin/_client-script.sh
index b1e4374..1ee6c4e 100755
--- a/opendj-sdk/opends/resource/bin/_client-script.sh
+++ b/opendj-sdk/opends/resource/bin/_client-script.sh
@@ -53,6 +53,11 @@
 # Set environment variables
 SCRIPT_UTIL_CMD=set-full-environment
 export SCRIPT_UTIL_CMD
+if [ -z "$NO_CHECK" ]
+then
+  NO_CHECK=1
+  export NO_CHECK
+fi
 .  "${INSTALL_ROOT}/lib/_script-util.sh"
 RETURN_CODE=$?
 if test ${RETURN_CODE} -ne 0
diff --git a/opendj-sdk/opends/resource/bin/_mixed-script.sh b/opendj-sdk/opends/resource/bin/_mixed-script.sh
index 6f92453..5b29f66 100644
--- a/opendj-sdk/opends/resource/bin/_mixed-script.sh
+++ b/opendj-sdk/opends/resource/bin/_mixed-script.sh
@@ -63,6 +63,8 @@
 # Set environment variables
 SCRIPT_UTIL_CMD=set-full-environment
 export SCRIPT_UTIL_CMD
+NO_CHECK=1
+export NO_CHECK
 .  "${INSTALL_ROOT}/lib/_script-util.sh"
 RETURN_CODE=$?
 if test ${RETURN_CODE} -ne 0
@@ -92,6 +94,8 @@
   # Set the environment to use the offline properties
   SCRIPT_NAME=${OLD_SCRIPT_NAME}.offline
   export SCRIPT_NAME
+  NO_CHECK=0
+  export NO_CHECK
   .  "${INSTALL_ROOT}/lib/_script-util.sh"
   RETURN_CODE=$?
   if test ${RETURN_CODE} -ne 0
diff --git a/opendj-sdk/opends/resource/bin/_script-util.sh b/opendj-sdk/opends/resource/bin/_script-util.sh
index c77e45c..7a3d522 100644
--- a/opendj-sdk/opends/resource/bin/_script-util.sh
+++ b/opendj-sdk/opends/resource/bin/_script-util.sh
@@ -160,6 +160,19 @@
   export CLASSPATH
 }
 
+isVersionOrHelp() {
+  for opt in `echo $*`
+  do
+	if [ $opt = "-V" ] || [ $opt = "--version" ] || 
+		[ $opt = "-H" ] || [ $opt = "--help" ] ||
+                [ $opt = "-F" ] || [ $opt = "--fullversion" ]
+	then
+		return 0
+	fi
+  done
+  return 1 
+}
+
 if test "${INSTALL_ROOT}" = ""
 then
   # Capture the current working directory so that we can change to it later.
@@ -175,18 +188,6 @@
 
 if test "${INSTANCE_ROOT}" = ""
 then
-  for opt in `echo $*`
-  do
-	if [ $opt = "-V" ] || [ $opt = "--version" ] || 
-		[ $opt = "-H" ] || [ $opt = "--help" ] 
-	then
-		INSTANCE_ROOT="not_needed"
-	fi
-  done
-fi
-
-if test "${INSTANCE_ROOT}" = ""
-then
   if [ -f ${INSTALL_ROOT}/configure ]
   then
     if [ -f /etc/opt/opends/instance.loc ]
@@ -200,8 +201,12 @@
     else
       if [ "${SCRIPT_NAME}" != "configure" ]
       then
-        echo "No instance found. Run ${INSTALL_ROOT}/configure to create it."
-        exit 1
+        isVersionOrHelp $*
+        if [ $? -eq 1 ]
+        then
+          echo "No instance found. Run ${INSTALL_ROOT}/configure to create it."
+          exit 1
+        fi
       fi
     fi
   else
@@ -262,17 +267,20 @@
 
 if [ "${SCRIPT_NAME}" != "configure" ]
 then 
-  NO_CHECK=0
-  for opt in `echo $*`
-  do
-    # No check for --version or --help option
-	if [ $opt = "-V" ] || [ $opt = "--version" ] || 
-		[ $opt = "-H" ] || [ $opt = "--help" ]  ||
-		[ $opt = "-F" ] || [ $opt = "--fullversion" ] 
-	then
-		NO_CHECK=1
-	fi
-  done
+  # Perform check unless it is specified not to do it
+  if [ -z "$NO_CHECK" ]
+  then
+     NO_CHECK=0
+  fi
+  if [ ${NO_CHECK} -eq 0 ]
+  then
+      # No check for --version or --help option
+      isVersionOrHelp $*
+      if [ $? -eq 0 ]
+      then
+        NO_CHECK=1
+      fi
+  fi
   if [ ${NO_CHECK} -eq 0 ]
   then
     set_classpath
diff --git a/opendj-sdk/opends/resource/bin/control-panel b/opendj-sdk/opends/resource/bin/control-panel
index d8a2b27..1c01f6a 100644
--- a/opendj-sdk/opends/resource/bin/control-panel
+++ b/opendj-sdk/opends/resource/bin/control-panel
@@ -33,5 +33,8 @@
 SCRIPT_NAME="control-panel"
 export SCRIPT_NAME
 
+NO_CHECK=0
+export NO_CHECK
+
 SCRIPT_DIR=`dirname "${0}"`
 "${SCRIPT_DIR}/../lib/_client-script.sh" "${@}"
diff --git a/opendj-sdk/opends/resource/bin/dsjavaproperties b/opendj-sdk/opends/resource/bin/dsjavaproperties
index b1a02e2..1931f98 100644
--- a/opendj-sdk/opends/resource/bin/dsjavaproperties
+++ b/opendj-sdk/opends/resource/bin/dsjavaproperties
@@ -33,5 +33,8 @@
 SCRIPT_NAME="dsjavaproperties"
 export SCRIPT_NAME
 
+NO_CHECK=0
+export NO_CHECK
+
 SCRIPT_DIR=`dirname "${0}"`
 "${SCRIPT_DIR}/../lib/_client-script.sh" "${@}"
diff --git a/opendj-sdk/opends/resource/bin/status-panel b/opendj-sdk/opends/resource/bin/status-panel
index d8a2b27..1c01f6a 100644
--- a/opendj-sdk/opends/resource/bin/status-panel
+++ b/opendj-sdk/opends/resource/bin/status-panel
@@ -33,5 +33,8 @@
 SCRIPT_NAME="control-panel"
 export SCRIPT_NAME
 
+NO_CHECK=0
+export NO_CHECK
+
 SCRIPT_DIR=`dirname "${0}"`
 "${SCRIPT_DIR}/../lib/_client-script.sh" "${@}"

--
Gitblit v1.10.0