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