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