start-ds revision 1024
16309N/A#!/bin/sh
16309N/A#
16309N/A# CDDL HEADER START
16309N/A#
16309N/A# The contents of this file are subject to the terms of the
16309N/A# Common Development and Distribution License, Version 1.0 only
16309N/A# (the "License"). You may not use this file except in compliance
16309N/A# with the License.
16309N/A#
16309N/A# You can obtain a copy of the license at
16309N/A# trunk/opends/resource/legal-notices/OpenDS.LICENSE
16309N/A# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
16309N/A# See the License for the specific language governing permissions
16309N/A# and limitations under the License.
16309N/A#
16309N/A# When distributing Covered Code, include this CDDL HEADER in each
16309N/A# file and include the License file at
16309N/A# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
16309N/A# add the following below this CDDL HEADER, with the fields enclosed
16309N/A# by brackets "[]" replaced with your own identifying information:
16309N/A# Portions Copyright [yyyy] [name of copyright owner]
16309N/A#
16309N/A# CDDL HEADER END
16309N/A#
16309N/A#
16309N/A# Portions Copyright 2006-2007 Sun Microsystems, Inc.
16309N/A
16309N/A
16309N/A# Capture the current working directory so that we can change to it later.
16309N/A# Then capture the location of this script and the Directory Server instance
16309N/A# root so that we can use them to create appropriate paths.
16309N/AWORKING_DIR=`pwd`
16309N/A
16309N/Acd `dirname "${0}"`
16309N/ASCRIPT_DIR=`pwd`
16309N/A
16309N/Acd ..
16309N/AINSTANCE_ROOT=`pwd`
16309N/Aexport INSTANCE_ROOT
16309N/A
16309N/Acd "${WORKING_DIR}"
16309N/A
16309N/A
16309N/A# See if JAVA_HOME is set. If not, then see if there is a java executable in
16309N/A# the path and try to figure it out.
16309N/Aif test -z "${JAVA_BIN}"
16309N/Athen
16309N/A if test -z "${JAVA_HOME}"
16309N/A then
16309N/A if test -f "${INSTANCE_ROOT}/bin/set-java-home"
16309N/A then
16309N/A . "${INSTANCE_ROOT}/bin/set-java-home"
16309N/A JAVA_BIN="${JAVA_HOME}/bin/java"
16309N/A export JAVA_BIN
16309N/A else
16309N/A JAVA_BIN=`which java 2> /dev/null`
16309N/A if test ${?} -eq 0
16309N/A then
16309N/A export JAVA_BIN
16309N/A else
16309N/A echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
16309N/A exit 1
16309N/A fi
16309N/A fi
16309N/A else
16309N/A JAVA_BIN="${JAVA_HOME}/bin/java"
16309N/A export JAVA_BIN
16309N/A fi
16309N/Afi
16309N/A
16309N/A
16309N/A# Explicitly set the PATH, LD_LIBRARY_PATH, LD_PRELOAD, and other important
16309N/A# system environment variables for security and compatibility reasons.
16309N/APATH=/bin:/usr/bin
16309N/ALD_LIBRARY_PATH=
16309N/ALD_LIBRARY_PATH_32=
16309N/ALD_LIBRARY_PATH_64=
16309N/ALD_PRELOAD=
16309N/ALD_PRELOAD_32=
16309N/ALD_PRELOAD_64=
16309N/Aexport PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 \
16309N/A LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_34
16309N/A
16309N/A
16309N/A# Configure the appropriate CLASSPATH.
16309N/ACLASSPATH=${INSTANCE_ROOT}/classes
16309N/Afor JAR in ${INSTANCE_ROOT}/lib/*.jar
16309N/Ado
16309N/A CLASSPATH=${CLASSPATH}:${JAR}
16309N/Adone
16309N/Aexport CLASSPATH
16309N/A
16309N/A
16309N/A# Specify the locations of important files that may be used when the server
16309N/A# is starting.
16309N/ACONFIG_FILE=${INSTANCE_ROOT}/config/config.ldif
16309N/APID_FILE=${INSTANCE_ROOT}/logs/server.pid
16309N/ALOG_FILE=${INSTANCE_ROOT}/logs/server.out
16309N/ASTARTING_FILE=${INSTANCE_ROOT}/logs/server.starting
16309N/A
16309N/A
16309N/A# Specify the script name so that it may be provided in command-line usage.
16309N/ASCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=start-ds"
16309N/Aexport SCRIPT_NAME_ARG
16309N/A
16309N/A
16309N/A# See if the provided set of arguments were sufficient for us to be able to
16309N/A# start the server or perform the requested operation. An exit code of 99
16309N/A# means that it should be possible to start the server. An exit code of 98
16309N/A# means that the server is already running and we shouldn't try to start it.
16309N/A# An exit code of anything else means that we're not trying to start the server
16309N/A# and we can just exit with that exit code.
16309N/A${JAVA_BIN} ${SCRIPT_NAME_ARG} org.opends.server.core.DirectoryServer \
16309N/A --configClass org.opends.server.extensions.ConfigFileHandler \
16309N/A --configFile "${CONFIG_FILE}" --checkStartability "${@}"
16309N/AEC=${?}
16309N/Aif test ${EC} -eq 99
16309N/Athen
16309N/A #
16309N/A # run detach
16309N/A #
16309N/A touch "${STARTING_FILE}"
16309N/A nohup "${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
16309N/A org.opends.server.core.DirectoryServer \
16309N/A --configClass org.opends.server.extensions.ConfigFileHandler \
16309N/A --configFile "${CONFIG_FILE}" "${@}" > "${LOG_FILE}" 2>&1 &
16309N/A echo $! > "${PID_FILE}"
16309N/A "${JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
16309N/A --targetFile "${STARTING_FILE}" --logFile "${LOG_FILE}"
16309N/A exit ${?}
16309N/Aelse
16309N/A if test ${EC} -eq 100
16309N/A then
16309N/A #
16309N/A # run no detach
16309N/A #
16309N/A echo $$ > "${PID_FILE}"
16309N/A rm -f "${LOG_FILE}"
16309N/A exec "${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
16309N/A org.opends.server.core.DirectoryServer \
16309N/A --configClass org.opends.server.extensions.ConfigFileHandler \
16309N/A --configFile "${CONFIG_FILE}" "${@}"
16309N/A else
16309N/A #
16309N/A # an error or the server is already started. Just return the code provided
16309N/A # by checkstartability
16309N/A #
16309N/A exit ${EC}
16309N/A fi
16309N/Afi
16309N/A