stop-ds revision 014019918f7e3844f558f6159b8d41517254edc2
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# CDDL HEADER START
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# The contents of this file are subject to the terms of the
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# Common Development and Distribution License, Version 1.0 only
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# (the "License"). You may not use this file except in compliance
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# with the License.
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# You can obtain a copy of the license at
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# trunk/opends/resource/legal-notices/OpenDS.LICENSE
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# See the License for the specific language governing permissions
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# and limitations under the License.
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# When distributing Covered Code, include this CDDL HEADER in each
4eb529f0471672590d77cf89ef23987ba2c95ff4Laszlo Hordos# file and include the License file at
4eb529f0471672590d77cf89ef23987ba2c95ff4Laszlo Hordos# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# add the following below this CDDL HEADER, with the fields enclosed
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# by brackets "[]" replaced with your own identifying information:
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# Portions Copyright [yyyy] [name of copyright owner]
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# CDDL HEADER END
7c64421614d420f1951773af3ce6a6111cef84b2Jake Feasel# Copyright 2006-2008 Sun Microsystems, Inc.
b564baaca75789be41eba24bb96e31f3ce5b10eeJake Feasel# This script may be used to request that the Directory Server shut down.
7c64421614d420f1951773af3ce6a6111cef84b2Jake Feasel# It operates in two different ways, depending on how it is invoked. If it
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# is invoked without any arguments and a local PID file is available, then it
54f30b716553d88ea9ebb010037f4c74eb1d69acPaul Bryan# will stop the server by sending a TERM signal to the process, and this
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# script will wait until the server has stopped before exiting. If any
e5c203467ee4398ae81a6adb63da7477451b2e77Laszlo Hordos# arguments were provided or there is no local PID file, then it will attempt
e5c203467ee4398ae81a6adb63da7477451b2e77Laszlo Hordos# to stop the server using an LDAP request.
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos# Capture the current working directory so that we can change to it later.
e5c203467ee4398ae81a6adb63da7477451b2e77Laszlo Hordos# Then capture the location of this script and the Directory Server instance
e5c203467ee4398ae81a6adb63da7477451b2e77Laszlo Hordos# root so that we can use them to create appropriate paths.
8166b048bd3e2106dbdeaa1a2b8a728952d788f4Laszlo Hordosif cat ${INSTALL_ROOT}/instance.loc | grep '^/' > /dev/null
8166b048bd3e2106dbdeaa1a2b8a728952d788f4Laszlo Hordos INSTANCE_ROOT=`cat ${INSTALL_ROOT}/instance.loc`
8166b048bd3e2106dbdeaa1a2b8a728952d788f4Laszlo Hordos INSTANCE_ROOT=${INSTALL_ROOT}/`cat ${INSTALL_ROOT}/instance.loc`
8166b048bd3e2106dbdeaa1a2b8a728952d788f4Laszlo Hordoscd "${WORKING_DIR}"
a14db14686bf9f6817c47e5c14e887d74dd615f0Laszlo Hordos# We keep this values to reset the environment before calling start-ds.
099518f7f744f2eaa4e23d3e0a92110f2e5e2811omebold# Specify the script name so that we can use the specified java properties.
2d7019e19039fd083850f76e54b6b26a7b06a8f2yaromin# Set environment variables
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel. "${INSTALL_ROOT}/lib/_script-util.sh"
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos"${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} \
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos org.opends.server.tools.StopDS --checkStoppability "${@}"
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos# Already stopped and nothing else to do.
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos # Already stopped and must start locally.
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel # Stop using system call
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos # Restart using system call
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel if test -f "${INSTANCE_ROOT}/logs/server.pid"
8698e80519313c98c8d5c6de06ae04cdfc816cafMatthias Tristl "${OPENDS_JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
8698e80519313c98c8d5c6de06ae04cdfc816cafMatthias Tristl --targetFile "${INSTANCE_ROOT}/logs/server.pid" \
8698e80519313c98c8d5c6de06ae04cdfc816cafMatthias Tristl echo "ERROR: Unable to find the server.pid file to determine the process"
8698e80519313c98c8d5c6de06ae04cdfc816cafMatthias Tristl echo " ID of the OpenDS process to terminate."
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel# Delete the pid file if the server is stopped (this can occur if the process
8698e80519313c98c8d5c6de06ae04cdfc816cafMatthias Tristl# has been killed using kill -9).
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel if test -f "${INSTANCE_ROOT}/logs/server.pid"
8698e80519313c98c8d5c6de06ae04cdfc816cafMatthias Tristl# Now if the user wants to restart the server, try to restart it if the server
8698e80519313c98c8d5c6de06ae04cdfc816cafMatthias Tristlif test ${MUST_START_USING_SYSTEM_CALL} -eq 0
8698e80519313c98c8d5c6de06ae04cdfc816cafMatthias Tristl# Set the original values that the user had on the environment in order to be
8698e80519313c98c8d5c6de06ae04cdfc816cafMatthias Tristl# sure that the start-ds script works with the proper arguments (in particular
8698e80519313c98c8d5c6de06ae04cdfc816cafMatthias Tristl# if the user specified not to overwrite the environment).
8698e80519313c98c8d5c6de06ae04cdfc816cafMatthias Tristl "${INSTALL_ROOT}/bin/start-ds"
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel# The user does not want to start the server locally and it is already stopped.
8698e80519313c98c8d5c6de06ae04cdfc816cafMatthias Tristl# If we've gotten here, then we should try to stop the server over LDAP.
8698e80519313c98c8d5c6de06ae04cdfc816cafMatthias Tristl"${OPENDS_JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \