From 9ce1475996a66be5463a1b5ad3c74af6d73097cb Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Thu, 22 Feb 2007 20:43:42 +0000
Subject: [PATCH] If the user provides no arguments or only the -R argument, we will assume that we want to stop the local server an we use the pid to kill it. If other arguments are passed (which appart from --help are arguments related to LDAP authentication) I will assume that we are trying to stop the server using protocol.
---
opends/resource/bin/stop-ds | 31 ++++++++++++++-
opends/resource/bin/stop-ds.bat | 44 +++++++++++++++++++--
2 files changed, 67 insertions(+), 8 deletions(-)
diff --git a/opends/resource/bin/stop-ds b/opends/resource/bin/stop-ds
index 117ef72..bf19ebd 100755
--- a/opends/resource/bin/stop-ds
+++ b/opends/resource/bin/stop-ds
@@ -106,9 +106,26 @@
# See if any arguments were provided and if a local PID file exists. If there
-# were no arguments and there is a PID file, then try to stop the server with
-# a kill command.
-if test -z "${1}"
+# were no arguments (or only the -R argument was passed) and there is a PID
+# file, then try to stop the server with a kill command.
+NO_ARG_OR_ONLY_RESTART=1
+RESTART=0
+for ARG in "${@}"
+do
+ if test "${ARG}" != "-R"
+ then
+ if test "${ARG}" != "--restart"
+ then
+ NO_ARG_OR_ONLY_RESTART=0
+ else
+ RESTART=1
+ fi
+ else
+ RESTART=1
+ fi
+done
+
+if test ${NO_ARG_OR_ONLY_RESTART} -eq 1
then
if test -f "${INSTANCE_ROOT}/logs/server.pid"
then
@@ -120,6 +137,14 @@
--targetFile "${INSTANCE_ROOT}/logs/server.pid" \
--logFile "${INSTANCE_ROOT}/logs/errors"
EXIT_CODE=${?}
+ if test "${RESTART}" -eq 1
+ then
+ if test "${EXIT_CODE}" -eq 0
+ then
+ "${INSTANCE_ROOT}/bin/start-ds"
+ EXIT_CODE=${?}
+ fi
+ fi
fi
exit ${EXIT_CODE}
fi
diff --git a/opends/resource/bin/stop-ds.bat b/opends/resource/bin/stop-ds.bat
index d367548..3543f22 100644
--- a/opends/resource/bin/stop-ds.bat
+++ b/opends/resource/bin/stop-ds.bat
@@ -31,14 +31,48 @@
set SCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=stop-ds"
set DIR_HOME=%~dP0..
-set ARGUMENTS=1
-if "%*" == "" set ARGUMENTS=0
-if "%ARGUMENTS%" == "1" goto stopWithLDAP
+set RESTART=0
+set NO_ARG_OR_ONLY_RESTART=0
+
+if "%*" == "" set NO_ARG_OR_ONLY_RESTART=1
+if "%NO_ARG_OR_ONLY_RESTART%" == "1" goto execute
+
+for %%x in (%*) DO if "%%x" == "-R" set RESTART=1
+for %%x in (%*) DO if "%%x" == "--restart" set RESTART=1
+
+goto testParameter1
+
+:testParameter1
+if not "%1" == "-R" goto testParameter1b
+goto testParameter2
+
+:testParameter1b
+if not "%1" == "--restart" goto execute
+goto testParameter2
+
+:testParameter2
+if not "%2" == "-R" goto testParameter2b
+goto testParameter3
+
+:testParameter2b
+if not "%2" == "--restart" goto execute
+goto testParameter3
+
+:testParameter3
+if not "%3" == "" goto execute
+set NO_ARG_OR_ONLY_RESTART=1
+goto execute
+
+:execute
+if "%NO_ARG_OR_ONLY_RESTART%" == "0" goto stopWithLDAP
if not exist "%DIR_HOME%\logs\server.pid" goto stopWithLDAP
-"%DIR_HOME%\lib\winlauncher.exe" stop "%DIR_HOME%"
+"%DIR_HOME%\lib\winlauncher.exe" stop "%DIR_HOME%"
+if not %errorlevel% == 0 goto end
+if "%RESTART%" == "1" "%DIR_HOME%\bin\start-ds.bat"
goto end
:stopWithLDAP
call "%~dP0\_client-script.bat" %*
-:end
\ No newline at end of file
+:end
+
--
Gitblit v1.10.0