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