stop-ds revision dde4e18690d219fc5aa41b62d3090ce8b2bbb1d7
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# CDDL HEADER START
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# The contents of this file are subject to the terms of the
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# Common Development and Distribution License, Version 1.0 only
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# (the "License"). You may not use this file except in compliance
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# with the License.
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# You can obtain a copy of the license at
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# See the License for the specific language governing permissions
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# and limitations under the License.
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# When distributing Covered Code, include this CDDL HEADER in each
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# file and include the License file at
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# add the following below this CDDL HEADER, with the fields enclosed
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# by brackets "[]" replaced with your own identifying * information:
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# Portions Copyright [yyyy] [name of copyright owner]
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# CDDL HEADER END
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# Portions Copyright 2006 Sun Microsystems, Inc.
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# This script may be used to request that the Directory Server shut down.
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# It operates in two different ways, depending on how it is invoked. If it
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# is invoked without any arguments and a local PID file is available, then it
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# will stop the server by sending a TERM signal to the process, and this
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# script will wait until the server has stopped before exiting. If any
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# arguments were provided or there is no local PID file, then it will attempt
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# to stop the server using an LDAP request.
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson# Capture the current working directory so that we can change to it later.
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson# Then capture the location of this script and the Directory Server instance
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson# root so that we can use them to create appropriate paths.
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilsoncd "${WORKING_DIR}"
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# See if JAVA_HOME is set. If not, then see if there is a java executable in
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# the path and try to figure it out.
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipeif test -z "${JAVA_BIN}"
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe if test -z "${JAVA_HOME}"
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson if test -f "${INSTANCE_ROOT}/bin/set-java-home"
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson . "${INSTANCE_ROOT}/bin/set-java-home"
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# Explicitly set the PATH, LD_LIBRARY_PATH, LD_PRELOAD, and other important
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# system environment variables for security and compatibility reasons.
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipeexport PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 \
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# Configure the appropriate CLASSPATH.
266c5071a91fda6a5159b08ea8d45261228d03d5neil_a_wilson# Specify the script name so that it may be provided in command-line usage.
266c5071a91fda6a5159b08ea8d45261228d03d5neil_a_wilsonSCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=stop-ds"
dde4e18690d219fc5aa41b62d3090ce8b2bbb1d7jvergara# If there were no arguments (or only the -R argument was passed) we assume that
dde4e18690d219fc5aa41b62d3090ce8b2bbb1d7jvergara# the server to be stopped is the local server. If this is the case we check if
dde4e18690d219fc5aa41b62d3090ce8b2bbb1d7jvergara# the server is running or not.
dde4e18690d219fc5aa41b62d3090ce8b2bbb1d7jvergara# If the server is running then try to stop the server with a kill command. If
dde4e18690d219fc5aa41b62d3090ce8b2bbb1d7jvergara# there are more arguments, try to stop the server using LDAP protocol.
dde4e18690d219fc5aa41b62d3090ce8b2bbb1d7jvergara # Use the code in StopDS class to know if the server is already
dde4e18690d219fc5aa41b62d3090ce8b2bbb1d7jvergara # stopped. An exit code of 99 means that the server is stopped.
dde4e18690d219fc5aa41b62d3090ce8b2bbb1d7jvergara if test -f "${INSTANCE_ROOT}/logs/server.pid"
dde4e18690d219fc5aa41b62d3090ce8b2bbb1d7jvergara # Delete the pid file if the server is stopped (this can occur if the process has
dde4e18690d219fc5aa41b62d3090ce8b2bbb1d7jvergara # been killed using kill -9).
dde4e18690d219fc5aa41b62d3090ce8b2bbb1d7jvergara if test -f "${INSTANCE_ROOT}/logs/server.pid"
dde4e18690d219fc5aa41b62d3090ce8b2bbb1d7jvergara # Now if the user wants to restart the server, try to restart it if the server
dde4e18690d219fc5aa41b62d3090ce8b2bbb1d7jvergara # is stopped.
dde4e18690d219fc5aa41b62d3090ce8b2bbb1d7jvergara "${INSTANCE_ROOT}/bin/start-ds"
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# If we've gotten here, then we should try to stop the server over LDAP.
266c5071a91fda6a5159b08ea8d45261228d03d5neil_a_wilson"${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \