stop-ds revision 37f9a536593b696e5a3dcec443e1475f22fb5afd
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
f71f7a61dec7c9089378d14493ad564a1dedf0b5neil_a_wilson# by brackets "[]" replaced with your own identifying information:
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# Portions Copyright [yyyy] [name of copyright owner]
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# CDDL HEADER END
f71f7a61dec7c9089378d14493ad564a1dedf0b5neil_a_wilson# Portions Copyright 2006-2007 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}"
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara# See if the environment variables are set. If not, then see if there is a java
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara# executable in the path and try to figure it out.
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergaraif test -z "${OPENDS_JAVA_BIN}"
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara if test -z "${OPENDS_JAVA_HOME}"
9da44d3de0a7180285a77b7e8d2426a72aca249ejvergara if test -f "${INSTANCE_ROOT}/lib/set-java-home"
9da44d3de0a7180285a77b7e8d2426a72aca249ejvergara . "${INSTANCE_ROOT}/lib/set-java-home"
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara if test -z "${JAVA_BIN}"
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara if test -z "${JAVA_HOME}"
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara echo "Please set OPENDS_JAVA_HOME to the root of a Java 5 (or later) 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"
39e085accf228684b9573bc8ad707a364ed6242ejvergara# Test that the provided JDK is 1.5 compatible.
39e085accf228684b9573bc8ad707a364ed6242ejvergaraif test -z "${JAVA_ARGS}"
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara "${OPENDS_JAVA_BIN}" org.opends.server.tools.InstallDS -t 2> /dev/null
39e085accf228684b9573bc8ad707a364ed6242ejvergara echo "ERROR: The detected Java version could not be used. Please set "
39e085accf228684b9573bc8ad707a364ed6242ejvergara echo " JAVA_HOME to the root of a Java 5.0 installation."
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara "${OPENDS_JAVA_BIN}" ${JAVA_ARGS} org.opends.server.tools.InstallDS -t 2> /dev/null
39e085accf228684b9573bc8ad707a364ed6242ejvergara echo "ERROR: The detected Java version could not be used with the specified"
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara echo "Java arguments. Please set OPENDS_JAVA_HOME to the root of a Java 5.0 installation."
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara"${OPENDS_JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
7070667c2dffad87009999bdeb16d5305e0afdbejvergara org.opends.server.tools.StopDS --checkStoppability "${@}"
7070667c2dffad87009999bdeb16d5305e0afdbejvergara# Already stopped and nothing else to do.
7070667c2dffad87009999bdeb16d5305e0afdbejvergara # Already stopped and must start locally.
7070667c2dffad87009999bdeb16d5305e0afdbejvergara # Stop using system call
7070667c2dffad87009999bdeb16d5305e0afdbejvergara # Restart using system call
7070667c2dffad87009999bdeb16d5305e0afdbejvergara if test -f "${INSTANCE_ROOT}/logs/server.pid"
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara "${OPENDS_JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
86580987a3bc88a2018319660f3b536c381938f5neil_a_wilson echo "ERROR: Unable to find the server.pid file to determine the process"
86580987a3bc88a2018319660f3b536c381938f5neil_a_wilson echo " ID of the OpenDS process to terminate."
7070667c2dffad87009999bdeb16d5305e0afdbejvergara# Delete the pid file if the server is stopped (this can occur if the process
7070667c2dffad87009999bdeb16d5305e0afdbejvergara# has been killed using kill -9).
7070667c2dffad87009999bdeb16d5305e0afdbejvergara if test -f "${INSTANCE_ROOT}/logs/server.pid"
7070667c2dffad87009999bdeb16d5305e0afdbejvergara# Now if the user wants to restart the server, try to restart it if the server
7070667c2dffad87009999bdeb16d5305e0afdbejvergara# is stopped.
61ae414d98d24ba4a72a905b07db9424353669f4neil_a_wilson "${INSTANCE_ROOT}/bin/start-ds"
7070667c2dffad87009999bdeb16d5305e0afdbejvergara# The user does not want to start the server locally and it is already stopped.
7070667c2dffad87009999bdeb16d5305e0afdbejvergara# Just exit.
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# If we've gotten here, then we should try to stop the server over LDAP.
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara"${OPENDS_JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \