stop-ds revision 814920a099ee946453263e682c7bb2cda00b7983
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# CDDL HEADER START
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# The contents of this file are subject to the terms of the
72ba327677b00dc4013e4ca19dd5ac4b87da63cebryce# Common Development and Distribution License, Version 1.0 only
72ba327677b00dc4013e4ca19dd5ac4b87da63cebryce# (the "License"). You may not use this file except in compliance
7923e87a291880ac8293fb5d1a1e1b759b23a091bryce# with the License.
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# You can obtain a copy of the license at
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# See the License for the specific language governing permissions
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# and limitations under the License.
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# When distributing Covered Code, include this CDDL HEADER in each
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# file and include the License file at
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# add the following below this CDDL HEADER, with the fields enclosed
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# by brackets "[]" replaced with your own identifying information:
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# Portions Copyright [yyyy] [name of copyright owner]
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# CDDL HEADER END
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# Copyright 2006-2009 Sun Microsystems, Inc.
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# Portions Copyright 2011 ForgeRock AS
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# This script may be used to request that the Directory Server shut down.
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# It operates in two different ways, depending on how it is invoked. If it
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# is invoked without any arguments and a local PID file is available, then it
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# will stop the server by sending a TERM signal to the process, and this
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# script will wait until the server has stopped before exiting. If any
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# arguments were provided or there is no local PID file, then it will attempt
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# to stop the server using an LDAP request.
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# Capture the current working directory so that we can change to it later.
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# Then capture the location of this script and the Directory Server instance
cac133768c18c89d4fccd4fc65d1a95232b51406bryce# root so that we can use them to create appropriate paths.
7923e87a291880ac8293fb5d1a1e1b759b23a091brycecd "${WORKING_DIR}"
7923e87a291880ac8293fb5d1a1e1b759b23a091bryce# We keep this values to reset the environment before calling start-ds.
7923e87a291880ac8293fb5d1a1e1b759b23a091bryce# Specify the script name so that we can use the specified java properties.
cac133768c18c89d4fccd4fc65d1a95232b51406bryce# check for presence of lib/_svc-opendj.sh file
cac133768c18c89d4fccd4fc65d1a95232b51406bryce# If present, we should be on Solaris/OpenSolaris and use SMF to start
cac133768c18c89d4fccd4fc65d1a95232b51406bryce# Check --exec. If not present, start OpenDJ from SMF
cac133768c18c89d4fccd4fc65d1a95232b51406bryceif test -f "${INSTALL_ROOT}/lib/_svc-opendj.sh"
cac133768c18c89d4fccd4fc65d1a95232b51406bryce elif [ "$1" != "-V" -a "$1" != "--version" -a "$1" != "-?" -a \
7923e87a291880ac8293fb5d1a1e1b759b23a091bryce#These options are not stopping the server, but checking version and help
7923e87a291880ac8293fb5d1a1e1b759b23a091bryce /usr/sbin/svcadm disable -t svc:/network/ldap/server:opendj
cac133768c18c89d4fccd4fc65d1a95232b51406bryce exec /usr/sbin/svcadm enable -t svc:/network/ldap/server:opendj
cac133768c18c89d4fccd4fc65d1a95232b51406bryce exec /usr/sbin/svcadm disable -t svc:/network/ldap/server:opendj
cac133768c18c89d4fccd4fc65d1a95232b51406bryce# Set environment variables
cac133768c18c89d4fccd4fc65d1a95232b51406bryce. "${INSTALL_ROOT}/lib/_script-util.sh"
cac133768c18c89d4fccd4fc65d1a95232b51406bryce"${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} \
cac133768c18c89d4fccd4fc65d1a95232b51406bryce org.opends.server.tools.StopDS --checkStoppability "${@}"
cac133768c18c89d4fccd4fc65d1a95232b51406bryce# Already stopped and nothing else to do.
cac133768c18c89d4fccd4fc65d1a95232b51406bryce # Already stopped and must start locally.
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce # Stop using system call
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce # Restart using system call
72ba327677b00dc4013e4ca19dd5ac4b87da63cebryce if test -f "${INSTANCE_ROOT}/logs/server.pid"
72ba327677b00dc4013e4ca19dd5ac4b87da63cebryce "${OPENDS_JAVA_BIN}" -client org.opends.server.tools.WaitForFileDelete \
72ba327677b00dc4013e4ca19dd5ac4b87da63cebryce echo "ERROR: Unable to find the server.pid file to determine the process"
72ba327677b00dc4013e4ca19dd5ac4b87da63cebryce echo " ID of the OpenDJ process to terminate."
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# Delete the pid file if the server is stopped (this can occur if the process
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# has been killed using kill -9).
72ba327677b00dc4013e4ca19dd5ac4b87da63cebryce if test -f "${INSTANCE_ROOT}/logs/server.pid"
72ba327677b00dc4013e4ca19dd5ac4b87da63cebryce# Now if the user wants to restart the server, try to restart it if the server
72ba327677b00dc4013e4ca19dd5ac4b87da63cebryce# is stopped.
72ba327677b00dc4013e4ca19dd5ac4b87da63cebryce# Set the original values that the user had on the environment in order to be
72ba327677b00dc4013e4ca19dd5ac4b87da63cebryce# sure that the start-ds script works with the proper arguments (in particular
72ba327677b00dc4013e4ca19dd5ac4b87da63cebryce# if the user specified not to overwrite the environment).
72ba327677b00dc4013e4ca19dd5ac4b87da63cebryce "${INSTALL_ROOT}/bin/start-ds"
72ba327677b00dc4013e4ca19dd5ac4b87da63cebryce# The user does not want to start the server locally and it is already stopped.
72ba327677b00dc4013e4ca19dd5ac4b87da63cebryce# Just exit.
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce# If we've gotten here, then we should try to stop the server over LDAP.
3114ead9a60b65191e92dea6c76c038c03a8f1dcbryce"${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} \