stop-ds revision 486
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#!/bin/sh
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Common Development and Distribution License, Version 1.0 only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# (the "License"). You may not use this file except in compliance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# You can obtain a copy of the license at
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# trunk/opends/resource/legal-notices/OpenDS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# file and include the License file at
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# add the following below this CDDL HEADER, with the fields enclosed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# by brackets "[]" replaced with your own identifying * information:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Portions Copyright 2006 Sun Microsystems, Inc.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# This script may be used to request that the Directory Server shut down.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# It operates in two different ways, depending on how it is invoked. If it
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# is invoked without any arguments and a local PID file is available, then it
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# will stop the server by sending a TERM signal to the process, and this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# script will wait until the server has stopped before exiting. If any
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# arguments were provided or there is no local PID file, then it will attempt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# to stop the server using an LDAP request.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# See if JAVA_HOME is set. If not, then see if there is a java executable in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# the path and try to figure it out.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteif test -z "${JAVA_BIN}"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortethen
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if test -z "${JAVA_HOME}"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte JAVA_BIN=`which java 2> /dev/null`
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if test ${?} -eq 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte export JAVA_BIN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fi
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte JAVA_BIN=${JAVA_HOME}/bin/java
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte export JAVA_BIN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fi
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefi
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Explicitly set the PATH, LD_LIBRARY_PATH, LD_PRELOAD, and other important
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# system environment variables for security and compatibility reasons.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortePATH=/bin:/usr/bin
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteLD_LIBRARY_PATH=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteLD_LIBRARY_PATH_32=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteLD_LIBRARY_PATH_64=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteLD_PRELOAD=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteLD_PRELOAD_32=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteLD_PRELOAD_64=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteexport 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 "${@}"