From b7bbff3851444b4390c87e23a846c5bdcab2700f Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Wed, 25 Apr 2007 12:35:08 +0000
Subject: [PATCH] Fix for issue 1273 (exception if JAVA_HOME undefined in scripts).
---
opends/resource/bin/stop-ds | 19 +++++++++
opends/resource/bin/stop-ds.bat | 11 +++++
opends/resource/bin/_server-script.sh | 3 -
opends/resource/bin/_server-script.bat | 2
opends/resource/bin/start-ds | 19 +++++++++
opends/resource/bin/_client-script.sh | 3 -
opends/resource/bin/_client-script.bat | 3 -
opends/resource/bin/start-ds.bat | 11 +++++
8 files changed, 62 insertions(+), 9 deletions(-)
diff --git a/opends/resource/bin/_client-script.bat b/opends/resource/bin/_client-script.bat
index 6d284f7..e20c48f 100644
--- a/opends/resource/bin/_client-script.bat
+++ b/opends/resource/bin/_client-script.bat
@@ -58,10 +58,9 @@
:noSetJavaHome
echo Error: JAVA_HOME environment variable is not set.
-echo Please set it to a valid Java 5 installation.
+echo Please set it to a valid Java 5 (or later) installation.
goto end
-
:setClassPath
FOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\bat\setcp.bat" %%x
diff --git a/opends/resource/bin/_client-script.sh b/opends/resource/bin/_client-script.sh
index 1f18797..225ea01 100755
--- a/opends/resource/bin/_client-script.sh
+++ b/opends/resource/bin/_client-script.sh
@@ -67,7 +67,7 @@
then
export JAVA_BIN
else
- echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
+ echo "Please set JAVA_HOME to the root of a Java 5 (or later) installation."
exit 1
fi
fi
@@ -99,6 +99,5 @@
done
export CLASSPATH
-
# Launch the appropriate server utility.
"${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} "${OPENDS_INVOKE_CLASS}" "${@}"
diff --git a/opends/resource/bin/_server-script.bat b/opends/resource/bin/_server-script.bat
index 2c39881..66ffb0d 100644
--- a/opends/resource/bin/_server-script.bat
+++ b/opends/resource/bin/_server-script.bat
@@ -58,7 +58,7 @@
:noSetJavaHome
echo Error: JAVA_HOME environment variable is not set.
-echo Please set it to a valid Java 5 installation.
+echo Please set it to a valid Java 5 (or later) installation.
goto end
:setClassPath
diff --git a/opends/resource/bin/_server-script.sh b/opends/resource/bin/_server-script.sh
index 141ac2e..ec5526a 100755
--- a/opends/resource/bin/_server-script.sh
+++ b/opends/resource/bin/_server-script.sh
@@ -67,7 +67,7 @@
then
export JAVA_BIN
else
- echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
+ echo "Please set JAVA_HOME to the root of a Java 5 (or later) installation."
exit 1
fi
fi
@@ -99,7 +99,6 @@
done
export CLASSPATH
-
# Launch the appropriate server utility.
"${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} "${OPENDS_INVOKE_CLASS}" \
--configClass org.opends.server.extensions.ConfigFileHandler \
diff --git a/opends/resource/bin/start-ds b/opends/resource/bin/start-ds
index 9b3fe59..36f8454 100755
--- a/opends/resource/bin/start-ds
+++ b/opends/resource/bin/start-ds
@@ -103,6 +103,25 @@
SCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=start-ds"
export SCRIPT_NAME_ARG
+# 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
+ 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.0 installation."
+ exit 1
+ fi
+else
+ "${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."
+ exit 1
+ fi
+fi
# See if the provided set of arguments were sufficient for us to be able to
# start the server or perform the requested operation. An exit code of 99
diff --git a/opends/resource/bin/start-ds.bat b/opends/resource/bin/start-ds.bat
index 8ea23b5..c8f7e34 100644
--- a/opends/resource/bin/start-ds.bat
+++ b/opends/resource/bin/start-ds.bat
@@ -48,7 +48,12 @@
:noSetJavaHome
echo Error: JAVA_HOME environment variable is not set.
-echo Please set it to a valid Java 5 installation.
+echo Please set it to a valid Java 5 (or later) installation.
+goto end
+
+:noValidJavaHome
+echo ERROR: The detected Java version could not be used. Please set
+echo JAVA_HOME to to a valid Java 5 (or later) installation.
goto end
:setClassPath
@@ -58,6 +63,10 @@
set SCRIPT_NAME_ARG=-Dorg.opends.server.scriptName=start-ds
+rem Test that the provided JDK is 1.5 compatible.
+"%JAVA_BIN%" org.opends.server.tools.InstallDS -t > NUL 2>&1
+if not %errorlevel% == 0 goto noValidJavaHome
+
"%JAVA_BIN%" -Xms8M -Xmx8M org.opends.server.core.DirectoryServer --configClass org.opends.server.extensions.ConfigFileHandler --configFile "%DIR_HOME%\config\config.ldif" --checkStartability %*
if %errorlevel% == 98 goto serverAlreadyStarted
diff --git a/opends/resource/bin/stop-ds b/opends/resource/bin/stop-ds
index 8269397..6a531ec 100755
--- a/opends/resource/bin/stop-ds
+++ b/opends/resource/bin/stop-ds
@@ -104,6 +104,25 @@
SCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=stop-ds"
export SCRIPT_NAME_ARG
+# 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
+ 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.0 installation."
+ exit 1
+ fi
+else
+ "${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."
+ exit 1
+ fi
+fi
"${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
org.opends.server.tools.StopDS --checkStoppability "${@}"
diff --git a/opends/resource/bin/stop-ds.bat b/opends/resource/bin/stop-ds.bat
index 5aad779..f135505 100644
--- a/opends/resource/bin/stop-ds.bat
+++ b/opends/resource/bin/stop-ds.bat
@@ -51,12 +51,21 @@
:noSetJavaHome
echo Error: JAVA_HOME environment variable is not set.
-echo Please set it to a valid Java 5 installation.
+echo Please set it to a valid Java 5 (or later) installation.
+goto end
+
+:noValidJavaHome
+echo ERROR: The detected Java version could not be used. Please set
+echo JAVA_HOME to to a valid Java 5 (or later) installation.
goto end
:setClassPath
FOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\bat\setcp.bat" %%x
+rem Test that the provided JDK is 1.5 compatible.
+"%JAVA_BIN%" org.opends.server.tools.InstallDS -t > NUL 2>&1
+if not %errorlevel% == 0 goto noValidJavaHome
+
"%JAVA_BIN%" -Xms8M -Xmx8M %SCRIPT_NAME_ARG% org.opends.server.tools.StopDS --checkStoppability %*
if %errorlevel% == 98 goto serverAlreadyStopped
--
Gitblit v1.10.0