stop-ds.bat revision 1920
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 Portions Copyright 2006-2007 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_ARG="-Dorg.opends.server.scriptName=stop-ds"
1920N/Afor %%i in (%~sf0) do set DIR_HOME=%%~dPsi..
828N/A
1298N/Aset INSTANCE_ROOT=%DIR_HOME%
1298N/A
1301N/Aset LOG="%INSTANCE_ROOT%\logs\native-windows.out"
1298N/Aset SCRIPT=stop-ds.bat
1298N/A
1298N/Arem This is the template to use for logging. Make sure to use >>
1298N/Arem echo %SCRIPT%: your-message-here >> %LOG%
1298N/Aecho %SCRIPT%: invoked >> %LOG%
1298N/A
857N/A:checkJavaBin
857N/Aif "%JAVA_BIN%" == "" goto noJavaBin
857N/Agoto setClassPath
857N/A
857N/A:noJavaBin
857N/Aif "%JAVA_HOME%" == "" goto noJavaHome
857N/Aif not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
857N/Aset JAVA_BIN=%JAVA_HOME%\bin\java.exe
857N/Agoto setClassPath
857N/A
857N/A:noJavaHome
1194N/Aif not exist "%DIR_HOME%\lib\set-java-home.bat" goto noSetJavaHome
1194N/Acall "%DIR_HOME%\lib\set-java-home.bat"
857N/Aset JAVA_BIN=%JAVA_HOME%\bin\java.exe
857N/Agoto setClassPath
857N/A
857N/A:noSetJavaHome
857N/Aecho Error: JAVA_HOME environment variable is not set.
1181N/Aecho Please set it to a valid Java 5 (or later) installation.
1298N/Aecho %SCRIPT%: JAVA_HOME environment variable is not set. >> %LOG%
1304N/Apause
1181N/Agoto end
1181N/A
1181N/A:noValidJavaHome
1298N/Aecho %SCRIPT%: The detected Java version could not be used. JAVA_HOME=[%JAVA_HOME%] >> %LOG%
1181N/Aecho ERROR: The detected Java version could not be used. Please set
1181N/Aecho JAVA_HOME to to a valid Java 5 (or later) installation.
1304N/Apause
857N/Agoto end
857N/A
857N/A:setClassPath
1194N/AFOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\lib\setcp.bat" %%x
857N/A
1298N/Aecho %SCRIPT%: CLASSPATH=%CLASSPATH% >> %LOG%
1298N/A
1181N/Arem Test that the provided JDK is 1.5 compatible.
1181N/A"%JAVA_BIN%" org.opends.server.tools.InstallDS -t > NUL 2>&1
1181N/Aif not %errorlevel% == 0 goto noValidJavaHome
1181N/A
961N/A"%JAVA_BIN%" -Xms8M -Xmx8M %SCRIPT_NAME_ARG% org.opends.server.tools.StopDS --checkStoppability %*
832N/A
961N/Aif %errorlevel% == 98 goto serverAlreadyStopped
961N/Aif %errorlevel% == 99 goto startUsingSystemCall
961N/Aif %errorlevel% == 100 goto stopUsingSystemCall
961N/Aif %errorlevel% == 101 goto restartUsingSystemCall
961N/Aif %errorlevel% == 102 goto stopUsingProtocol
961N/Aif %errorlevel% == 103 goto stopAsWindowsService
961N/Aif %errorlevel% == 104 goto restartAsWindowsService
961N/Arem An error or we display usage
961N/Agoto end
832N/A
961N/A:serverAlreadyStopped
1298N/Aecho %SCRIPT%: server already stopped >> %LOG%
961N/Aif exist "%DIR_HOME%\logs\server.pid" erase "%DIR_HOME%\logs\server.pid"
961N/Agoto end
832N/A
961N/A:startUsingSystemCall
1298N/Aecho %SCRIPT%: start using system call >> %LOG%
968N/A"%DIR_HOME%\bat\start-ds.bat"
961N/Agoto end
832N/A
961N/A:stopUsingSystemCall
1298N/Aecho %SCRIPT%: stop using system call >> %LOG%
961N/A"%DIR_HOME%\lib\winlauncher.exe" stop "%DIR_HOME%"
961N/Agoto end
857N/A
961N/A:restartUsingSystemCall
1298N/Aecho %SCRIPT%: restart using system call >> %LOG%
832N/A"%DIR_HOME%\lib\winlauncher.exe" stop "%DIR_HOME%"
832N/Aif not %errorlevel% == 0 goto end
961N/Agoto startUsingSystemCall
857N/A
961N/A:stopUsingProtocol
1298N/Aecho %SCRIPT%: stop using protocol >> %LOG%
1194N/Acall "%DIR_HOME%\lib\_client-script.bat" %*
961N/Agoto end
961N/A
961N/A:stopAsWindowsService
1298N/Aecho %SCRIPT%: stop as windows service >> %LOG%
961N/A"%JAVA_BIN%" -Xms8M -Xmx8M org.opends.server.tools.StopWindowsService
828N/Agoto end
828N/A
961N/A:restartAsWindowsService
1298N/Aecho %SCRIPT%: restart as windows service, stopping >> %LOG%
961N/A"%JAVA_BIN%" -Xms8M -Xmx8M org.opends.server.tools.StopWindowsService
961N/Aif not %errorlevel% == 0 goto end
1298N/Aecho %SCRIPT%: restart as windows service, starting >> %LOG%
961N/A"%JAVA_BIN%" -Xms8M -Xmx8M org.opends.server.tools.StartWindowsService
961N/A"%JAVA_BIN%" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete --targetFile "%DIR_HOME%\logs\server.startingservice"
961N/Arem Type the contents the winwervice.out file and delete it.
961N/Aif exist "%DIR_HOME%\logs\winservice.out" type "%DIR_HOME%\logs\winservice.out"
961N/Aif exist "%DIR_HOME%\logs\winservice.out" erase "%DIR_HOME%\logs\winservice.out"
961N/Agoto end
828N/A
832N/A:end
832N/A
1298N/Aecho %SCRIPT%: finished >> %LOG%