stop-ds revision 2976
6fe48fb46e53ffc37542853a1edb74cb481b7d94Automatic Updater# CDDL HEADER START
c7fd128f8ea8a527fe27c1b95ab46df7155bc8e4Tinderbox User# The contents of this file are subject to the terms of the
ba9e87b35e561bc7354ce3f4b9685b747b7be507Tinderbox User# Common Development and Distribution License, Version 1.0 only
1f9754245cbd5eec2d2a667bb292f62f72386d4bMark Andrews# (the "License"). You may not use this file except in compliance
59663800d2ec04777dae2791dd92aa563faf94c8Evan Hunt# with the License.
1f9754245cbd5eec2d2a667bb292f62f72386d4bMark Andrews# You can obtain a copy of the license at
59663800d2ec04777dae2791dd92aa563faf94c8Evan Hunt# trunk/opends/resource/legal-notices/OpenDS.LICENSE
0726d872f6f36901ea09321df57084614e5bb6faTinderbox User# See the License for the specific language governing permissions
1ca2cf024391992fe14b2df7d3ae0f575d074452Evan Hunt# and limitations under the License.
8de3f14f1c300c3e1ed99084cc03485b42c92bf1Tinderbox User# When distributing Covered Code, include this CDDL HEADER in each
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# file and include the License file at
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User# add the following below this CDDL HEADER, with the fields enclosed
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# by brackets "[]" replaced with your own identifying information:
2b7254075b883d70852a2757210793603085a0f1Tinderbox User# Portions Copyright [yyyy] [name of copyright owner]
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# CDDL HEADER END
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# Portions Copyright 2006-2007 Sun Microsystems, Inc.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# This script may be used to request that the Directory Server shut down.
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# It operates in two different ways, depending on how it is invoked. If it
415d630b6309922caee8469384a6fab75cf05032Mark Andrews# is invoked without any arguments and a local PID file is available, then it
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# will stop the server by sending a TERM signal to the process, and this
415d630b6309922caee8469384a6fab75cf05032Mark Andrews# script will wait until the server has stopped before exiting. If any
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrews# arguments were provided or there is no local PID file, then it will attempt
9218b940febade3085fd6d95a15e67d5f94833f0Tinderbox User# to stop the server using an LDAP request.
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews# Capture the current working directory so that we can change to it later.
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrews# Then capture the location of this script and the Directory Server instance
9218b940febade3085fd6d95a15e67d5f94833f0Tinderbox User# root so that we can use them to create appropriate paths.
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Huntcd "${WORKING_DIR}"
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# Specify the script name so that we can use the specified java properties.
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt# Set environment variables
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark AndrewsSCRIPT_UTIL_CMD=set-full-environment-and-test-java
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews. "${INSTANCE_ROOT}/lib/_script-util.sh"
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater"${OPENDS_JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews org.opends.server.tools.StopDS --checkStoppability "${@}"
015055b6e23f5c08f6a5b34726f90b62597e9e45Tinderbox User# Already stopped and nothing else to do.
2ae159b376dac23870d8005563c585acf85a4b5aEvan Hunt # Already stopped and must start locally.
9218b940febade3085fd6d95a15e67d5f94833f0Tinderbox User # Stop using system call
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews # Restart using system call
415d630b6309922caee8469384a6fab75cf05032Mark Andrews if test -f "${INSTANCE_ROOT}/logs/server.pid"
9218b940febade3085fd6d95a15e67d5f94833f0Tinderbox User kill `cat "${INSTANCE_ROOT}/logs/server.pid"`
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews "${OPENDS_JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
ebe53509ca55a141131c104b6d722236b606e0efTinderbox User --targetFile "${INSTANCE_ROOT}/logs/server.pid" \
baeaed18341c015e9ad54ffa21973184c1bc432bMark Andrews echo "ERROR: Unable to find the server.pid file to determine the process"
2a31bd531072824ef252c18303859d6af7451b00Francis Dupont echo " ID of the OpenDS process to terminate."
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews# Delete the pid file if the server is stopped (this can occur if the process
33b0d10552ea5f7716385b2cedff64daa1486c50Tinderbox User# has been killed using kill -9).
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews if test -f "${INSTANCE_ROOT}/logs/server.pid"
66317da170ed35b08f5847db2d48b225826327cbTinderbox User# Now if the user wants to restart the server, try to restart it if the server
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# is stopped.
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews "${INSTANCE_ROOT}/bin/start-ds"
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# The user does not want to start the server locally and it is already stopped.
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrews# If we've gotten here, then we should try to stop the server over LDAP.
9218b940febade3085fd6d95a15e67d5f94833f0Tinderbox User"${OPENDS_JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \