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