start-ds revision 536
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# 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# Specify the locations of important files that may be used when the server
486N/A# is starting.
486N/ACONFIG_FILE=${INSTANCE_ROOT}/config/config.ldif
486N/APID_FILE=${INSTANCE_ROOT}/logs/server.pid
486N/ALOG_FILE=${INSTANCE_ROOT}/logs/server.out
486N/ASTARTING_FILE=${INSTANCE_ROOT}/logs/server.starting
486N/A
486N/A
536N/A# Specify the script name so that it may be provided in command-line usage.
536N/ASCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=start-ds"
536N/Aexport SCRIPT_NAME_ARG
536N/A
536N/A
502N/A# See if an "-N" or a "--nodetach" argument was provided as a command-line
502N/A# argument. If it was, then don't use nohup to send to the background, and
502N/A# send all output to both the console and a lot file.
502N/ANODETACH=0
502N/Afor ARG in "${@}"
502N/Ado
502N/A if test "${ARG}" = "-N"
502N/A then
502N/A NODETACH=1
502N/A else
502N/A ARG=`echo ${ARG} | tr '[A-Z]' '[a-z]'`
502N/A if test "${ARG}" = "--nodetach"
502N/A then
502N/A NODETACH=1
502N/A fi
502N/A fi
502N/Adone
502N/A
502N/Aif test ${NODETACH} -eq 1
486N/Athen
486N/A echo $$ > "${PID_FILE}"
486N/A rm -f "${PID_FILE}" "${LOG_FILE}"
536N/A exec "${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
486N/A org.opends.server.core.DirectoryServer \
486N/A --configClass org.opends.server.extensions.ConfigFileHandler \
502N/A --configFile "${CONFIG_FILE}" "${@}"
486N/Aelse
486N/A touch "${STARTING_FILE}"
536N/A nohup "${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
486N/A org.opends.server.core.DirectoryServer \
486N/A --configClass org.opends.server.extensions.ConfigFileHandler \
486N/A --configFile "${CONFIG_FILE}" "${@}" > "${LOG_FILE}" 2>&1 &
486N/A echo $! > "${PID_FILE}"
486N/A "${JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
486N/A --targetFile "${STARTING_FILE}" --logFile "${LOG_FILE}"
486N/A exit ${?}
486N/Afi