stop-ds revision 4edb61f8b0f8ce9f62d803c706612376498672b4
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# CDDL HEADER START
4a14ce5ba00ab7bc55c99ffdcf59c7a4ab902721Automatic Updater# The contents of this file are subject to the terms of the
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# Common Development and Distribution License, Version 1.0 only
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# (the "License"). You may not use this file except in compliance
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# with the License.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# You can obtain a copy of the license at
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# trunk/opends/resource/legal-notices/OpenDS.LICENSE
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# See the License for the specific language governing permissions
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# and limitations under the License.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# When distributing Covered Code, include this CDDL HEADER in each
ea94d370123a5892f6c47a97f21d1b28d44bb168Tinderbox User# file and include the License file at
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# add the following below this CDDL HEADER, with the fields enclosed
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# by brackets "[]" replaced with your own identifying * information:
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# Portions Copyright [yyyy] [name of copyright owner]
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# CDDL HEADER END
c3dc968140ab7f04795acc7835e4e89ccb0c0a27Tinderbox User# Portions Copyright 2006 Sun Microsystems, Inc.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# This script may be used to request that the Directory Server shut down.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# It operates in two different ways, depending on how it is invoked. If it
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# is invoked without any arguments and a local PID file is available, then it
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# will stop the server by sending a TERM signal to the process, and this
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# script will wait until the server has stopped before exiting. If any
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater# arguments were provided or there is no local PID file, then it will attempt
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# to stop the server using an LDAP request.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# See if JAVA_HOME is set. If not, then see if there is a java executable in
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# the path and try to figure it out.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsif test -z "${JAVA_BIN}"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews if test -z "${JAVA_HOME}"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# Explicitly set the PATH, LD_LIBRARY_PATH, LD_PRELOAD, and other important
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# system environment variables for security and compatibility reasons.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsexport PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 \
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# Capture the current working directory so that we can change to it later.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# Then capture the location of this script and the Directory Server instance
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater# root so that we can use them to create appropriate paths.
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updatercd "${WORKING_DIR}"
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater# Configure the appropriate CLASSPATH.
dba3c818ae00b10388d31703e86a28415db398acTinderbox User# See if any arguments were provided and if a local PID file exists. If there
43b94483957d3168796a816ed86cf097518817dcTinderbox User# were no arguments and there is a PID file, then try to stop the server with
be6c1c506161e6f45fcff5d0425f78801bc267c1Automatic Updater# a kill command.
8ec3c085233cedb22b05da36e2773c8f357a7e45Automatic Updaterif test -z "${1}"
8ec3c085233cedb22b05da36e2773c8f357a7e45Automatic Updater if test -f "${INSTANCE_ROOT}/logs/server.pid"
8ec3c085233cedb22b05da36e2773c8f357a7e45Automatic Updater kill `cat "${INSTANCE_ROOT}/logs/server.pid"`
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater "${JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater --targetFile "${INSTANCE_ROOT}/logs/server.pid" \
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# If we've gotten here, then we should try to stop the server over LDAP.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews"${JAVA_BIN}" ${JAVA_ARGS} org.opends.server.tools.StopDS "${@}"