stop-ds revision 873
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering# CDDL HEADER START
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering# The contents of this file are subject to the terms of the
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering# Common Development and Distribution License, Version 1.0 only
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering# (the "License"). You may not use this file except in compliance
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering# with the License.
9fa2f41077b2d76685058836f602f38715b5eef3Kay Sievers# You can obtain a copy of the license at
9fa2f41077b2d76685058836f602f38715b5eef3Kay Sievers# trunk/opends/resource/legal-notices/OpenDS.LICENSE
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering# See the License for the specific language governing permissions
9fa2f41077b2d76685058836f602f38715b5eef3Kay Sievers# and limitations under the License.
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering# When distributing Covered Code, include this CDDL HEADER in each
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering# file and include the License file at
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering# add the following below this CDDL HEADER, with the fields enclosed
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering# by brackets "[]" replaced with your own identifying information:
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering# Portions Copyright [yyyy] [name of copyright owner]
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering# CDDL HEADER END
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering# Portions Copyright 2006-2007 Sun Microsystems, Inc.
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering# This script may be used to request that the Directory Server shut down.
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering# It operates in two different ways, depending on how it is invoked. If it
673eab9bf0d2d79a72f3d7c430807b8786de7ee3Lennart Poettering# is invoked without any arguments and a local PID file is available, then it
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering# will stop the server by sending a TERM signal to the process, and this
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering# script will wait until the server has stopped before exiting. If any
7c09aafd269bc04dcfc07d94c4ee583b7b0751e6Kay Sievers# arguments were provided or there is no local PID file, then it will attempt
673eab9bf0d2d79a72f3d7c430807b8786de7ee3Lennart Poettering# to stop the server using an LDAP request.
b7f44df59a7f76d2bd5302df2f5ec9be9b7fa2faLennart Poettering# Capture the current working directory so that we can change to it later.
b7f44df59a7f76d2bd5302df2f5ec9be9b7fa2faLennart Poettering# Then capture the location of this script and the Directory Server instance
b7f44df59a7f76d2bd5302df2f5ec9be9b7fa2faLennart Poettering# root so that we can use them to create appropriate paths.
3ede835a0486f2ecc025dede0b33e9a1edc06d30Lennart Poetteringcd "${WORKING_DIR}"
7b17a7d72f5ba5ad838b19803534c56a46f3bce9Lennart Poettering# See if JAVA_HOME is set. If not, then see if there is a java executable in
7b17a7d72f5ba5ad838b19803534c56a46f3bce9Lennart Poettering# the path and try to figure it out.
7b17a7d72f5ba5ad838b19803534c56a46f3bce9Lennart Poetteringif test -z "${JAVA_BIN}"
2cc86f094a8c316f7feb0336df3827a3264b116dZbigniew Jędrzejewski-Szmek if test -z "${JAVA_HOME}"
2cc86f094a8c316f7feb0336df3827a3264b116dZbigniew Jędrzejewski-Szmek if test -f "${INSTANCE_ROOT}/bin/set-java-home"
c3d2d86d4f40593a361e33b101f5384a8ea2cdb7Tom Gundersen . "${INSTANCE_ROOT}/bin/set-java-home"
f1c24fea94e19cf2108abbeed1d36ded7102ab98Zbigniew Jędrzejewski-Szmek echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
b62cfcea00862ccbf0e5e297f8a339f70987edefMichael Biebl# Explicitly set the PATH, LD_LIBRARY_PATH, LD_PRELOAD, and other important
19d5d4cb6a89c844e298eb65bce6ba0fa9d58b91Zbigniew Jędrzejewski-Szmek# system environment variables for security and compatibility reasons.
bf9e477c92506884977d6c8d761969e105528f3eKay Sieversexport PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 \
6705c2df468a6afb4f8f834822780add123065e2Lennart Poettering# Configure the appropriate CLASSPATH.
21bc923aa35d455cdef1607eb7022608c705c9f3Lennart Poettering# Specify the script name so that it may be provided in command-line usage.
21bc923aa35d455cdef1607eb7022608c705c9f3Lennart PoetteringSCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=stop-ds"
21bc923aa35d455cdef1607eb7022608c705c9f3Lennart Poettering# If there were no arguments (or only the -R argument was passed) we assume that
21bc923aa35d455cdef1607eb7022608c705c9f3Lennart Poettering# the server to be stopped is the local server. If this is the case we check if
ed1c99fcc13f279eccf25fc20427eb92867da245Lennart Poettering# the server is running or not.
21bc923aa35d455cdef1607eb7022608c705c9f3Lennart Poettering# If the server is running then try to stop the server with a kill command. If
21bc923aa35d455cdef1607eb7022608c705c9f3Lennart Poettering# there are more arguments, try to stop the server using LDAP protocol.
fc7a744cc44cdb80bf9bc6304fc3f80ca2cb65f9Lennart Poettering # Use the code in StopDS class to know if the server is already
fc7a744cc44cdb80bf9bc6304fc3f80ca2cb65f9Lennart Poettering # stopped. An exit code of 99 means that the server is stopped.
fc7a744cc44cdb80bf9bc6304fc3f80ca2cb65f9Lennart Poettering "${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
EC=${?}
if test -f "${INSTANCE_ROOT}/logs/server.pid"
EXIT_CODE=${?}
EXIT_CODE=${?}
if test -f "${INSTANCE_ROOT}/logs/server.pid"
EXIT_CODE=${?}
exit ${EXIT_CODE}