stop-ds revision 486
6499N/A#!/bin/sh
6499N/A#
6499N/A# CDDL HEADER START
6499N/A#
6499N/A# The contents of this file are subject to the terms of the
6499N/A# Common Development and Distribution License, Version 1.0 only
6499N/A# (the "License"). You may not use this file except in compliance
6499N/A# with the License.
6499N/A#
6499N/A# You can obtain a copy of the license at
6499N/A# trunk/opends/resource/legal-notices/OpenDS.LICENSE
6499N/A# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
6499N/A# See the License for the specific language governing permissions
6499N/A# and limitations under the License.
6499N/A#
6499N/A# When distributing Covered Code, include this CDDL HEADER in each
6499N/A# file and include the License file at
6499N/A# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
6499N/A# add the following below this CDDL HEADER, with the fields enclosed
6499N/A# by brackets "[]" replaced with your own identifying * information:
6499N/A# Portions Copyright [yyyy] [name of copyright owner]
6499N/A#
6499N/A# CDDL HEADER END
6499N/A#
6499N/A#
6499N/A# Portions Copyright 2006 Sun Microsystems, Inc.
6499N/A
6499N/A
6499N/A# This script may be used to request that the Directory Server shut down.
6499N/A# It operates in two different ways, depending on how it is invoked. If it
6499N/A# is invoked without any arguments and a local PID file is available, then it
6499N/A# will stop the server by sending a TERM signal to the process, and this
6499N/A# script will wait until the server has stopped before exiting. If any
6499N/A# arguments were provided or there is no local PID file, then it will attempt
6499N/A# to stop the server using an LDAP request.
6499N/A
6499N/A
6499N/A# See if JAVA_HOME is set. If not, then see if there is a java executable in
6499N/A# the path and try to figure it out.
6499N/Aif test -z "${JAVA_BIN}"
6499N/Athen
6499N/A if test -z "${JAVA_HOME}"
6499N/A then
6499N/A JAVA_BIN=`which java 2> /dev/null`
6499N/A if test ${?} -eq 0
6499N/A then
6499N/A export JAVA_BIN
6499N/A else
6499N/A echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
6499N/A exit 1
6499N/A fi
6499N/A else
6499N/A JAVA_BIN=${JAVA_HOME}/bin/java
6499N/A export JAVA_BIN
6499N/A fi
6499N/Afi
6499N/A
6499N/A
6499N/A# Explicitly set the PATH, LD_LIBRARY_PATH, LD_PRELOAD, and other important
6499N/A# system environment variables for security and compatibility reasons.
6499N/APATH=/bin:/usr/bin
6499N/ALD_LIBRARY_PATH=
6499N/ALD_LIBRARY_PATH_32=
LD_LIBRARY_PATH_64=
LD_PRELOAD=
LD_PRELOAD_32=
LD_PRELOAD_64=
export PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 \
LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_34
# Capture the current working directory so that we can change to it later.
# Then capture the location of this script and the Directory Server instance
# root so that we can use them to create appropriate paths.
WORKING_DIR=`pwd`
cd `dirname "${0}"`
SCRIPT_DIR=`pwd`
cd ..
INSTANCE_ROOT=`pwd`
export INSTANCE_ROOT
cd "${WORKING_DIR}"
# Configure the appropriate CLASSPATH.
CLASSPATH=${INSTANCE_ROOT}/classes
for JAR in ${INSTANCE_ROOT}/lib/*.jar
do
CLASSPATH=${CLASSPATH}:${JAR}
done
export CLASSPATH
# See if any arguments were provided and if a local PID file exists. If there
# were no arguments and there is a PID file, then try to stop the server with
# a kill command.
if test -z "${1}"
then
if test -f "${INSTANCE_ROOT}/logs/server.pid"
then
kill `cat "${INSTANCE_ROOT}/logs/server.pid"`
EXIT_CODE=${?}
if test "${EXIT_CODE}" -eq 0
then
"${JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
--targetFile "${INSTANCE_ROOT}/logs/server.pid" \
--logFile "${INSTANCE_ROOT}/logs/errors"
EXIT_CODE=${?}
fi
exit ${EXIT_CODE}
fi
fi
# If we've gotten here, then we should try to stop the server over LDAP.
"${JAVA_BIN}" ${JAVA_ARGS} org.opends.server.tools.StopDS "${@}"