From bc67703dbdca616d9a6a34b25382ec417bd8c22e Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Wed, 07 May 2008 12:01:48 +0000
Subject: [PATCH] Fix for issues:

---
 opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java |    9 +++++++--
 opends/resource/bin/start-ds.bat                                  |   26 ++++++++++++++++++--------
 2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/opends/resource/bin/start-ds.bat b/opends/resource/bin/start-ds.bat
index a4010ab..299623c 100644
--- a/opends/resource/bin/start-ds.bat
+++ b/opends/resource/bin/start-ds.bat
@@ -41,7 +41,9 @@
 rem Set environment variables
 set SCRIPT_UTIL_CMD=set-full-environment-and-test-java
 call "%INSTANCE_ROOT%\lib\_script-util.bat"
-if NOT %errorlevel% == 0 exit %errorlevel%
+
+set ERROR_CODE=%errorlevel%
+if NOT %ERROR_CODE% == 0 goto exitErrorCode
 
 echo %SCRIPT%: CLASSPATH=%CLASSPATH% >> %LOG%
 
@@ -58,11 +60,13 @@
 if %errorlevel% == 102 goto runDetachCalledByWinService
 if %errorlevel% == 103 goto runDetachQuiet
 if %errorlevel% == 104 goto runNoDetachQuiet
-goto end
+set ERROR_CODE=%errorlevel%
+goto exitErrorCode
 
 :serverAlreadyStarted
 echo %SCRIPT%: Server already started  >> %LOG%
-goto end
+set ERROR_CODE=0
+goto exitErrorCode
 
 :runNoDetach
 echo %SCRIPT%: Run no detach  >> %LOG%
@@ -70,7 +74,8 @@
 if not exist "%DIR_HOME%\logs\server.starting" echo. > "%DIR_HOME%\logs\server.starting"
 if exist "%DIR_HOME%\lib\set-java-args.bat %SCRIPT%" DO call "%DIR_HOME%\lib\set-java-args.bat"
 "%OPENDS_JAVA_BIN%" %OPENDS_SERVER_JAVA_ARGS% %SCRIPT_NAME_ARG% org.opends.server.core.DirectoryServer --configClass org.opends.server.extensions.ConfigFileHandler --configFile "%DIR_HOME%\config\config.ldif" %*
-goto end
+set ERROR_CODE=%errorlevel%
+goto exitErrorCode
 
 :runNoDetachQuiet
 echo %SCRIPT%: Run no detach  >> %LOG%
@@ -78,8 +83,8 @@
 if not exist "%DIR_HOME%\logs\server.starting" echo. > "%DIR_HOME%\logs\server.starting"
 if exist "%DIR_HOME%\lib\set-java-args.bat %SCRIPT%" DO call "%DIR_HOME%\lib\set-java-args.bat"
 "%OPENDS_JAVA_BIN%" %OPENDS_SERVER_JAVA_ARGS% %SCRIPT_NAME_ARG% org.opends.server.core.DirectoryServer --configClass org.opends.server.extensions.ConfigFileHandler --configFile "%DIR_HOME%\config\config.ldif" %* >> %LOG%
-goto end
-
+set ERROR_CODE=%errorlevel%
+goto exitErrorCode
 
 :runDetach
 echo %SCRIPT%: Run detach  >> %LOG%
@@ -132,12 +137,17 @@
 
 :serverStarted
 echo %SCRIPT%: finished >> %LOG%
-exit 0
+set ERROR_CODE=0
+goto exitErrorCode
 
 :serverNotStarted
 echo %SCRIPT%: finished >> %LOG%
-exit 1
+set ERROR_CODE=1
+goto exitErrorCode
 
+:exitErrorCode
+if "%OPENDS_EXIT_NO_BACKGROUND%" == "true" exit %ERROR_CODE%
+exit /B %ERROR_CODE%
 
 :end
 echo %SCRIPT%: finished >> %LOG%
diff --git a/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java b/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java
index 6b9b3af..5d9ff74 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java
@@ -81,6 +81,8 @@
     try {
       Map<String, String> env = pb.environment();
       env.put(SetupUtils.OPENDS_JAVA_HOME, System.getProperty("java.home"));
+      // This is required in order the return code to be valid.
+      env.put("OPENDS_EXIT_NO_BACKGROUND", "true");
       final Process process = pb.start();
       is = process.getInputStream();
       out = process.getOutputStream();
@@ -98,8 +100,11 @@
               try
               {
                 Thread.sleep(5000);
-                fOut.write(Constants.LINE_SEPARATOR.getBytes());
-                fOut.flush();
+                if (!done[0])
+                {
+                  fOut.write(Constants.LINE_SEPARATOR.getBytes());
+                  fOut.flush();
+                }
               }
               catch (Throwable t)
               {

--
Gitblit v1.10.0