1339N/A# $Id: stop-ds 553 2013-04-13 17:41:34Z elkner $ 919N/A# The contents of this file are subject to the terms of the 919N/A# Common Development and Distribution License, Version 1.0 only 919N/A# (the "License"). You may not use this file except in compliance 919N/A# You can obtain a copy of the license at 919N/A# See the License for the specific language governing permissions 919N/A# and limitations under the License. 919N/A# When distributing Covered Code, include this CDDL HEADER in each 919N/A# file and include the License file at 919N/A# add the following below this CDDL HEADER, with the fields enclosed 919N/A# by brackets "[]" replaced with your own identifying information: 561N/A# Portions Copyright [yyyy] [name of copyright owner] 561N/A# Copyright 2006-2009 Sun Microsystems, Inc. 970N/A# Portions Copyright 2011 ForgeRock AS 970N/A# Portions Copyright 2013 Jens Elkner 970N/A# This script may be used to request that the Directory Server shut down. 561N/A# It operates in two different ways, depending on how it is invoked. If it 1043N/A# is invoked without any arguments and a local PID file is available, then it 561N/A# will stop the server by sending a TERM signal to the process, and this 911N/A# script will wait until the server has stopped before exiting. If any 1043N/A# arguments were provided or there is no local PID file, then it will attempt 1043N/A# to stop the server using an LDAP request. 1339N/A# We keep this values to reset the environment before calling start-ds. # Set environment variables checkEnv -i
'set-full-environment-and-test-java' "$@" [[ ${
ARG} ==
'-R' || ${
ARG} ==
'--restart' ]] &&
RESTART=
1 &&
break # If restart is requested, check whether the service is not disabled. If so, # use svcadm to restart, otherwise fall through. if (( ${RESTART} )) && [[ -n
"${SMF_FMRI}" &&
${ uname -s ; } ==
'SunOS' ]]
if [[ -n ${
STATE} && ${
STATE} !=
'disabled' ]];
then print -
u2 "Restarting service '${SMF_FMRI}' ..." (( ${RC} != 0 )) &&
print -
u2 'Done.' ||
print -
u2 'Failed.' if (( ${RC} == 98 ));
then # Already stopped and nothing else to do. elif (( ${RC} == 99 || ${RC} == 105 ));
then # Already stopped and must start locally elif (( ${RC} == 100 ));
then elif (( ${RC} == 101 || ${RC} == 106 ));
then # Restart using system call elif (( ${RC} != 102 ));
then # If != stop using protocol print -
u2 'ERROR: Unable to find the server.pid file to determine' \
'the process ID of the OpenDJ process to terminate.' # Delete the pid file if the server is stopped (this can occur if the process # has been killed using kill -9). # Now if the user wants to restart the server, try to restart it if the server # Set the original values that the user had on the environment in order # to be sure that the start-ds script works with the proper arguments # (in particular if the user specified not to overwrite the environment) # The user does not want to start the server locally and it is already stopped. # If we've gotten here, then we should try to stop the server over LDAP.