stop-ds.bat revision 4495
0N/A
0N/A@echo off
0N/Arem CDDL HEADER START
0N/Arem
0N/Arem The contents of this file are subject to the terms of the
0N/Arem Common Development and Distribution License, Version 1.0 only
0N/Arem (the "License"). You may not use this file except in compliance
0N/Arem with the License.
0N/Arem
0N/Arem You can obtain a copy of the license at
0N/Arem trunk/opends/resource/legal-notices/OpenDS.LICENSE
0N/Arem or https://OpenDS.dev.java.net/OpenDS.LICENSE.
0N/Arem See the License for the specific language governing permissions
0N/Arem and limitations under the License.
0N/Arem
0N/Arem When distributing Covered Code, include this CDDL HEADER in each
0N/Arem file and include the License file at
0N/Arem trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
0N/Arem add the following below this CDDL HEADER, with the fields enclosed
873N/Arem by brackets "[]" replaced with your own identifying information:
0N/Arem Portions Copyright [yyyy] [name of copyright owner]
0N/Arem
0N/Arem CDDL HEADER END
0N/Arem
0N/Arem
828N/Arem Copyright 2006-2009 Sun Microsystems, Inc.
0N/A
0N/Asetlocal
0N/A
857N/Aset PATH=%SystemRoot%
857N/A
481N/Aset OPENDS_INVOKE_CLASS="org.opends.server.tools.StopDS"
536N/Aset SCRIPT_NAME=stop-ds
828N/Afor %%i in (%~sf0) do set DIR_HOME=%%~dPsi..
828N/A
857N/Arem We keep this values to reset the environment before calling start-ds.
857N/Aset ORIGINAL_JAVA_ARGS=%OPENDS_JAVA_ARGS%
857N/Aset ORIGINAL_JAVA_HOME=%OPENDS_JAVA_HOME%
857N/Aset ORIGINAL_JAVA_BIN=%OPENDS_JAVA_BIN%
857N/A
857N/Aset INSTALL_ROOT=%DIR_HOME%
857N/A
857N/Aset INSTANCE_DIR=
857N/Afor /f "delims=" %%a in (%INSTALL_ROOT%\instance.loc) do (
857N/A set INSTANCE_DIR=%%a
857N/A)
857N/Aset CUR_DIR=%~dp0
857N/Acd /d%INSTALL_ROOT%
857N/Acd /d%INSTANCE_DIR%
857N/Aset INSTANCE_ROOT=%CD%
857N/Acd /d%CUR_DIR%
857N/A
857N/Aset LOG="%INSTANCE_ROOT%\logs\native-windows.out"
857N/Aset SCRIPT=stop-ds.bat
857N/A
857N/Arem This is the template to use for logging. Make sure to use >>
857N/Arem echo %SCRIPT%: your-message-here >> %LOG%
857N/Aecho %SCRIPT%: invoked >> %LOG%
857N/A
961N/Arem Set environment variables
832N/Aset SCRIPT_UTIL_CMD=set-full-environment-and-test-java
961N/Acall "%INSTALL_ROOT%\lib\_script-util.bat" %*
961N/Aif NOT %errorlevel% == 0 exit /B %errorlevel%
961N/A
961N/Aecho %SCRIPT%: CLASSPATH=%CLASSPATH% >> %LOG%
961N/A
961N/A"%OPENDS_JAVA_BIN%" -Xms8M -Xmx8M %SCRIPT_NAME_ARG% org.opends.server.tools.StopDS --checkStoppability %*
961N/A
961N/Aif %errorlevel% == 98 goto serverAlreadyStopped
961N/Aif %errorlevel% == 99 goto startUsingSystemCall
832N/Aif %errorlevel% == 100 goto stopUsingSystemCall
961N/Aif %errorlevel% == 101 goto restartUsingSystemCall
961N/Aif %errorlevel% == 102 goto stopUsingProtocol
961N/Aif %errorlevel% == 103 goto stopAsWindowsService
832N/Aif %errorlevel% == 104 goto restartAsWindowsService
961N/Arem An error or we display usage
961N/Agoto end
961N/A
832N/A:serverAlreadyStopped
961N/Aecho %SCRIPT%: server already stopped >> %LOG%
961N/Aif exist "%INSTANCE_ROOT%\logs\server.pid" erase "%INSTANCE_ROOT%\logs\server.pid"
961N/Agoto end
857N/A
961N/A:startUsingSystemCall
832N/Aecho %SCRIPT%: start using system call >> %LOG%
832N/Arem Set the original values that the user had on the environment in order to be
961N/Arem sure that the start-ds script works with the proper arguments (in particular
857N/Arem if the user specified not to overwrite the environment).
961N/Aset OPENDS_JAVA_ARGS=%ORIGINAL_JAVA_ARGS%
961N/Aset OPENDS_JAVA_HOME=%ORIGINAL_JAVA_HOME%
961N/Aset OPENDS_JAVA_BIN=%ORIGINAL_JAVA_BIN%
961N/A"%INSTALL_ROOT%\bat\start-ds.bat"
961N/Agoto end
961N/A
828N/A:stopUsingSystemCall
828N/Aecho %SCRIPT%: stop using system call >> %LOG%
961N/A"%INSTALL_ROOT%\lib\winlauncher.exe" stop "%INSTANCE_ROOT%"
961N/Agoto end
961N/A
961N/A:restartUsingSystemCall
961N/Aecho %SCRIPT%: restart using system call >> %LOG%
961N/A"%INSTALL_ROOT%\lib\winlauncher.exe" stop "%INSTANCE_ROOT%"
961N/Aif not %errorlevel% == 0 goto end
961N/Agoto startUsingSystemCall
961N/A
828N/A:stopUsingProtocol
832N/Aecho %SCRIPT%: stop using protocol >> %LOG%
832N/Acall "%INSTALL_ROOT%\lib\_client-script.bat" %*
goto end
:stopAsWindowsService
echo %SCRIPT%: stop as windows service >> %LOG%
"%OPENDS_JAVA_BIN%" -Xms8M -Xmx8M org.opends.server.tools.StopWindowsService
goto end
:restartAsWindowsService
echo %SCRIPT%: restart as windows service, stopping >> %LOG%
"%OPENDS_JAVA_BIN%" -Xms8M -Xmx8M org.opends.server.tools.StopWindowsService
if not %errorlevel% == 0 goto end
echo %SCRIPT%: restart as windows service, starting >> %LOG%
"%OPENDS_JAVA_BIN%" -Xms8M -Xmx8M org.opends.server.tools.StartWindowsService
"%OPENDS_JAVA_BIN%" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete --targetFile "%INSTANCE_ROOT%\logs\server.startingservice"
rem Type the contents the winwervice.out file and delete it.
if exist "%INSTANCE_ROOT%\logs\winservice.out" type "%INSTANCE_ROOT%\logs\winservice.out"
if exist "%INSTANCE_ROOT%\logs\winservice.out" erase "%INSTANCE_ROOT%\logs\winservice.out"
goto end
:end
echo %SCRIPT%: finished >> %LOG%