stop-ds revision 2296
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson#!/bin/sh
499b34cea04a46823d003d4c0520c8b03e8513cbBrian Wellington#
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# CDDL HEADER START
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson#
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson# The contents of this file are subject to the terms of the
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson# Common Development and Distribution License, Version 1.0 only
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# (the "License"). You may not use this file except in compliance
15a44745412679c30a6d022733925af70a38b715David Lawrence# with the License.
15a44745412679c30a6d022733925af70a38b715David Lawrence#
15a44745412679c30a6d022733925af70a38b715David Lawrence# You can obtain a copy of the license at
15a44745412679c30a6d022733925af70a38b715David Lawrence# trunk/opends/resource/legal-notices/OpenDS.LICENSE
15a44745412679c30a6d022733925af70a38b715David Lawrence# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
15a44745412679c30a6d022733925af70a38b715David Lawrence# See the License for the specific language governing permissions
15a44745412679c30a6d022733925af70a38b715David Lawrence# and limitations under the License.
15a44745412679c30a6d022733925af70a38b715David Lawrence#
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson# When distributing Covered Code, include this CDDL HEADER in each
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson# file and include the License file at
499b34cea04a46823d003d4c0520c8b03e8513cbBrian Wellington# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson# add the following below this CDDL HEADER, with the fields enclosed
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson# by brackets "[]" replaced with your own identifying information:
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson# Portions Copyright [yyyy] [name of copyright owner]
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson#
9779deddba39f1ccc5e73e3c0d721f2253bcaccaBob Halley# CDDL HEADER END
0d32cdd9a07819b03f2b07fc8fdcdb0a227eee0bMark Andrews#
6028d1ce0380d0ba7f6c6ecd1ad20b31ddd1becbDavid Lawrence#
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence# Portions Copyright 2006-2007 Sun Microsystems, Inc.
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence
e01ecff4b1562a24e6de7e9396c60e9dffdb78ceAndreas Gustafsson
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson# This script may be used to request that the Directory Server shut down.
63bb6b854b6db073856b0f2b2924d1af33e0eaf6Andreas Gustafsson# It operates in two different ways, depending on how it is invoked. If it
911ed0d3bee586b3bec42cb6c376d5cc6c0e1e24Brian Wellington# is invoked without any arguments and a local PID file is available, then it
63bb6b854b6db073856b0f2b2924d1af33e0eaf6Andreas Gustafsson# will stop the server by sending a TERM signal to the process, and this
63bb6b854b6db073856b0f2b2924d1af33e0eaf6Andreas Gustafsson# script will wait until the server has stopped before exiting. If any
63bb6b854b6db073856b0f2b2924d1af33e0eaf6Andreas Gustafsson# arguments were provided or there is no local PID file, then it will attempt
63bb6b854b6db073856b0f2b2924d1af33e0eaf6Andreas Gustafsson# to stop the server using an LDAP request.
f4e4111795ceb13066d09c38723afacb04e33ad4Mark Andrews
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson# Capture the current working directory so that we can change to it later.
63bb6b854b6db073856b0f2b2924d1af33e0eaf6Andreas Gustafsson# Then capture the location of this script and the Directory Server instance
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson# root so that we can use them to create appropriate paths.
ba6fd2580863759baedd9c47153602b19006a324Andreas GustafssonWORKING_DIR=`pwd`
0f78de4d61441acbb0af7088c2dfda60a7ed5500Brian Wellington
63bb6b854b6db073856b0f2b2924d1af33e0eaf6Andreas Gustafssoncd `dirname "${0}"`
81ce556e020e7f51adfb4eae6b31659f59b0fc4bAndreas GustafssonSCRIPT_DIR=`pwd`
d60f5b9bc8c1e1f7ddebc6c7834f7550a8e8be6fBob Halley
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafssoncd ..
4fe8755480c108a1232b7189fd5434ab35a6b623Brian WellingtonINSTANCE_ROOT=`pwd`
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellingtonexport INSTANCE_ROOT
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafssoncd "${WORKING_DIR}"
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson
f2fdfe7c42f3b10f3653f851ce5a0a90ee5ac1f9David Lawrence# See if JAVA_HOME is set. If not, then see if there is a java executable in
f2fdfe7c42f3b10f3653f851ce5a0a90ee5ac1f9David Lawrence# the path and try to figure it out.
f2fdfe7c42f3b10f3653f851ce5a0a90ee5ac1f9David Lawrenceif test -z "${JAVA_BIN}"
f2fdfe7c42f3b10f3653f851ce5a0a90ee5ac1f9David Lawrencethen
f2fdfe7c42f3b10f3653f851ce5a0a90ee5ac1f9David Lawrence if test -z "${JAVA_HOME}"
f2fdfe7c42f3b10f3653f851ce5a0a90ee5ac1f9David Lawrence then
f2fdfe7c42f3b10f3653f851ce5a0a90ee5ac1f9David Lawrence if test -f "${INSTANCE_ROOT}/lib/set-java-home"
f2fdfe7c42f3b10f3653f851ce5a0a90ee5ac1f9David Lawrence then
f2fdfe7c42f3b10f3653f851ce5a0a90ee5ac1f9David Lawrence . "${INSTANCE_ROOT}/lib/set-java-home"
f2fdfe7c42f3b10f3653f851ce5a0a90ee5ac1f9David Lawrence JAVA_BIN="${JAVA_HOME}/bin/java"
f2fdfe7c42f3b10f3653f851ce5a0a90ee5ac1f9David Lawrence export JAVA_BIN
f2fdfe7c42f3b10f3653f851ce5a0a90ee5ac1f9David Lawrence else
f2fdfe7c42f3b10f3653f851ce5a0a90ee5ac1f9David Lawrence JAVA_BIN=`which java 2> /dev/null`
f2fdfe7c42f3b10f3653f851ce5a0a90ee5ac1f9David Lawrence if test ${?} -eq 0
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson then
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson export JAVA_BIN
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson else
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson exit 1
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson fi
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson fi
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson else
0b87eaccdbbac3911ce54521a5a9e84aabce70c5Mark Andrews JAVA_BIN="${JAVA_HOME}/bin/java"
0b87eaccdbbac3911ce54521a5a9e84aabce70c5Mark Andrews export JAVA_BIN
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson fi
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafssonfi
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson# Explicitly set the PATH, LD_LIBRARY_PATH, LD_PRELOAD, and other important
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson# system environment variables for security and compatibility reasons.
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas GustafssonPATH=/bin:/usr/bin
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas GustafssonLD_LIBRARY_PATH=
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas GustafssonLD_LIBRARY_PATH_32=
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas GustafssonLD_LIBRARY_PATH_64=
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas GustafssonLD_PRELOAD=
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas GustafssonLD_PRELOAD_32=
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas GustafssonLD_PRELOAD_64=
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafssonexport PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 \
897ba5e12014b2001dba9ef7fceeec7d9182e447Andreas Gustafsson LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_34
4c2ed12aaa258590a1b889463c1421ff9c38cc0aAndreas Gustafsson
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson
9d34fb782676f3cc5fccc2e50468549934110f1cAndreas Gustafsson# Configure the appropriate CLASSPATH.
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas GustafssonCLASSPATH=${INSTANCE_ROOT}/classes
897ba5e12014b2001dba9ef7fceeec7d9182e447Andreas Gustafssonfor JAR in ${INSTANCE_ROOT}/lib/*.jar
897ba5e12014b2001dba9ef7fceeec7d9182e447Andreas Gustafssondo
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson CLASSPATH=${CLASSPATH}:${JAR}
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafssondone
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafssonexport CLASSPATH
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson
35b22d104a60d8f2305100e00ae0d6cb5efe1722Andreas Gustafsson
35b22d104a60d8f2305100e00ae0d6cb5efe1722Andreas Gustafsson# Specify the script name so that it may be provided in command-line usage.
35b22d104a60d8f2305100e00ae0d6cb5efe1722Andreas GustafssonSCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=stop-ds"
35b22d104a60d8f2305100e00ae0d6cb5efe1722Andreas Gustafssonexport SCRIPT_NAME_ARG
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
35b22d104a60d8f2305100e00ae0d6cb5efe1722Andreas Gustafsson# Test that the provided JDK is 1.5 compatible.
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafssonif test -z "${JAVA_ARGS}"
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafssonthen
0d32cdd9a07819b03f2b07fc8fdcdb0a227eee0bMark Andrews "${JAVA_BIN}" org.opends.server.tools.InstallDS -t 2> /dev/null
0d32cdd9a07819b03f2b07fc8fdcdb0a227eee0bMark Andrews if test ${?} -ne 0
0d32cdd9a07819b03f2b07fc8fdcdb0a227eee0bMark Andrews then
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson echo "ERROR: The detected Java version could not be used. Please set "
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson echo " JAVA_HOME to the root of a Java 5.0 installation."
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson exit 1
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson fi
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafssonelse
80afc68f7784868d68f544df4be0e9f9711323a5Andreas Gustafsson "${JAVA_BIN}" ${JAVA_ARGS} org.opends.server.tools.InstallDS -t 2> /dev/null
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson if test ${?} -ne 0
4b887af61910a8d7ed1d2d013d956f56e54c0e23Andreas Gustafsson then
4b887af61910a8d7ed1d2d013d956f56e54c0e23Andreas Gustafsson echo "ERROR: The detected Java version could not be used with the specified"
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson echo "Java arguments. Please set JAVA_HOME to the root of a Java 5.0 installation."
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson exit 1
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson fi
80afc68f7784868d68f544df4be0e9f9711323a5Andreas Gustafssonfi
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson"${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson org.opends.server.tools.StopDS --checkStoppability "${@}"
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas GustafssonEC=${?}
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas GustafssonSTOPPED=1
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas GustafssonEXIT_CODE=1
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas GustafssonMUST_START_USING_SYSTEM_CALL=1
80afc68f7784868d68f544df4be0e9f9711323a5Andreas GustafssonMUST_STOP_USING_SYSTEM_CALL=1
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas GustafssonQUIET_MODE=1
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafssonif test ${EC} -eq 98
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson#
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson# Already stopped and nothing else to do.
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson#
0f78de4d61441acbb0af7088c2dfda60a7ed5500Brian Wellingtonthen
0f78de4d61441acbb0af7088c2dfda60a7ed5500Brian Wellington STOPPED=0
3f6dc1703f76a24b34ed3bc839447291c33ca837Brian Wellingtonelse
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington if test ${EC} -eq 99 -o ${EC} -eq 105
4fe8755480c108a1232b7189fd5434ab35a6b623Brian Wellington #
0f78de4d61441acbb0af7088c2dfda60a7ed5500Brian Wellington # Already stopped and must start locally.
0b87eaccdbbac3911ce54521a5a9e84aabce70c5Mark Andrews #
0f78de4d61441acbb0af7088c2dfda60a7ed5500Brian Wellington then
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson STOPPED=0
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson MUST_START_USING_SYSTEM_CALL=0
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence if test ${EC} -eq 105
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence then
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson QUIET_MODE=0
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson fi
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson else
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson if test ${EC} -eq 100
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson then
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson #
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence # Stop using system call
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson #
80afc68f7784868d68f544df4be0e9f9711323a5Andreas Gustafsson MUST_STOP_USING_SYSTEM_CALL=0
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson else
6cd4630de6946cb9d9e35f3603af11219b9353a1Brian Wellington if test ${EC} -eq 101 -o ${EC} -eq 106
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence then
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson #
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson # Restart using system call
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson #
4c2ed12aaa258590a1b889463c1421ff9c38cc0aAndreas Gustafsson MUST_STOP_USING_SYSTEM_CALL=0
4c2ed12aaa258590a1b889463c1421ff9c38cc0aAndreas Gustafsson MUST_START_USING_SYSTEM_CALL=0
4c2ed12aaa258590a1b889463c1421ff9c38cc0aAndreas Gustafsson if test ${EC} -eq 106
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson then
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson QUIET_MODE=0
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson fi
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson else
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson if test ${EC} -ne 102
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff then
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson exit ${EC}
9d34fb782676f3cc5fccc2e50468549934110f1cAndreas Gustafsson fi
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson fi
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson fi
81ce556e020e7f51adfb4eae6b31659f59b0fc4bAndreas Gustafsson fi
a474ba139d758cd78507621e947119706197718eAndreas Gustafssonfi
9d34fb782676f3cc5fccc2e50468549934110f1cAndreas Gustafsson
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafssonif test ${MUST_STOP_USING_SYSTEM_CALL} -eq 0
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafssonthen
4b887af61910a8d7ed1d2d013d956f56e54c0e23Andreas Gustafsson if test -f "${INSTANCE_ROOT}/logs/server.pid"
3f6dc1703f76a24b34ed3bc839447291c33ca837Brian Wellington then
897ba5e12014b2001dba9ef7fceeec7d9182e447Andreas Gustafsson kill `cat "${INSTANCE_ROOT}/logs/server.pid"`
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson EXIT_CODE=${?}
897ba5e12014b2001dba9ef7fceeec7d9182e447Andreas Gustafsson if test ${EXIT_CODE} -eq 0
897ba5e12014b2001dba9ef7fceeec7d9182e447Andreas Gustafsson then
897ba5e12014b2001dba9ef7fceeec7d9182e447Andreas Gustafsson "${JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson --targetFile "${INSTANCE_ROOT}/logs/server.pid" \
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson --logFile "${INSTANCE_ROOT}/logs/errors"
897ba5e12014b2001dba9ef7fceeec7d9182e447Andreas Gustafsson EXIT_CODE=${?}
897ba5e12014b2001dba9ef7fceeec7d9182e447Andreas Gustafsson if test ${EXIT_CODE} -eq 0
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson then
897ba5e12014b2001dba9ef7fceeec7d9182e447Andreas Gustafsson STOPPED=0
897ba5e12014b2001dba9ef7fceeec7d9182e447Andreas Gustafsson fi
897ba5e12014b2001dba9ef7fceeec7d9182e447Andreas Gustafsson fi
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson else
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson echo "ERROR: Unable to find the server.pid file to determine the process"
897ba5e12014b2001dba9ef7fceeec7d9182e447Andreas Gustafsson echo " ID of the OpenDS process to terminate."
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson exit 1
897ba5e12014b2001dba9ef7fceeec7d9182e447Andreas Gustafsson fi
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafssonfi
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson
897ba5e12014b2001dba9ef7fceeec7d9182e447Andreas Gustafsson# Delete the pid file if the server is stopped (this can occur if the process
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson# has been killed using kill -9).
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafssonif test ${STOPPED} -eq 0
897ba5e12014b2001dba9ef7fceeec7d9182e447Andreas Gustafssonthen
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson if test -f "${INSTANCE_ROOT}/logs/server.pid"
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson then
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson rm "${INSTANCE_ROOT}/logs/server.pid"
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson fi
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafssonfi
897ba5e12014b2001dba9ef7fceeec7d9182e447Andreas Gustafsson
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson# Now if the user wants to restart the server, try to restart it if the server
ee205e0662ac12562cb8d519f7fbad29188a82d2David Lawrence# is stopped.
ee205e0662ac12562cb8d519f7fbad29188a82d2David Lawrenceif test ${MUST_START_USING_SYSTEM_CALL} -eq 0
ee205e0662ac12562cb8d519f7fbad29188a82d2David Lawrencethen
ee205e0662ac12562cb8d519f7fbad29188a82d2David Lawrence if test ${STOPPED} -eq 0
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson then
5862cce82b091b356129810d15341a48984c03b1Andreas Gustafsson if test ${QUIET_MODE} -eq 0
f4e4111795ceb13066d09c38723afacb04e33ad4Mark Andrews then
f4e4111795ceb13066d09c38723afacb04e33ad4Mark Andrews "${INSTANCE_ROOT}/bin/start-ds" --quiet
5862cce82b091b356129810d15341a48984c03b1Andreas Gustafsson EXIT_CODE=${?}
f4e4111795ceb13066d09c38723afacb04e33ad4Mark Andrews exit ${EXIT_CODE}
f4e4111795ceb13066d09c38723afacb04e33ad4Mark Andrews else
63bb6b854b6db073856b0f2b2924d1af33e0eaf6Andreas Gustafsson "${INSTANCE_ROOT}/bin/start-ds"
897ba5e12014b2001dba9ef7fceeec7d9182e447Andreas Gustafsson EXIT_CODE=${?}
63bb6b854b6db073856b0f2b2924d1af33e0eaf6Andreas Gustafsson exit ${EXIT_CODE}
5862cce82b091b356129810d15341a48984c03b1Andreas Gustafsson fi
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson fi
80afc68f7784868d68f544df4be0e9f9711323a5Andreas Gustafsson#
80afc68f7784868d68f544df4be0e9f9711323a5Andreas Gustafsson# The user does not want to start the server locally and it is already stopped.
80afc68f7784868d68f544df4be0e9f9711323a5Andreas Gustafsson# Just exit.
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson#
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffelse
897ba5e12014b2001dba9ef7fceeec7d9182e447Andreas Gustafsson if test ${STOPPED} -eq 0
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff then
b8c76784615808b5e5c53b91b782973e2ede7728Andreas Gustafsson exit 0
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson fi
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafssonfi
d60f5b9bc8c1e1f7ddebc6c7834f7550a8e8be6fBob Halley
d60f5b9bc8c1e1f7ddebc6c7834f7550a8e8be6fBob Halley# If we've gotten here, then we should try to stop the server over LDAP.
d60f5b9bc8c1e1f7ddebc6c7834f7550a8e8be6fBob Halley"${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson org.opends.server.tools.StopDS "${@}"
4cd3d6df39927315e3fadc07a8da3788175f4195Andreas Gustafsson