start-ds revision 619
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# CDDL HEADER START
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# The contents of this file are subject to the terms of the
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Common Development and Distribution License, Version 1.0 only
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# (the "License"). You may not use this file except in compliance
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# with the License.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# You can obtain a copy of the license at
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# trunk/opends/resource/legal-notices/OpenDS.LICENSE
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# See the License for the specific language governing permissions
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# and limitations under the License.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# When distributing Covered Code, include this CDDL HEADER in each
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# file and include the License file at
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# add the following below this CDDL HEADER, with the fields enclosed
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# by brackets "[]" replaced with your own identifying * information:
6398f22526303343193a18e514602f1af6fb29cbNikolai Kondrashov# Portions Copyright [yyyy] [name of copyright owner]
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# CDDL HEADER END
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Portions Copyright 2006 Sun Microsystems, Inc.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Capture the current working directory so that we can change to it later.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Then capture the location of this script and the Directory Server instance
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# root so that we can use them to create appropriate paths.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashovcd "${WORKING_DIR}"
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# See if JAVA_HOME is set. If not, then see if there is a java executable in
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# the path and try to figure it out.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashovif test -z "${JAVA_BIN}"
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov if test -z "${JAVA_HOME}"
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov if test -f "${INSTANCE_ROOT}/bin/set-java-home"
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov . "${INSTANCE_ROOT}/bin/set-java-home"
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Explicitly set the PATH, LD_LIBRARY_PATH, LD_PRELOAD, and other important
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# system environment variables for security and compatibility reasons.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashovexport PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Configure the appropriate CLASSPATH.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Specify the locations of important files that may be used when the server
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai KondrashovCONFIG_FILE=${INSTANCE_ROOT}/config/config.ldif
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai KondrashovSTARTING_FILE=${INSTANCE_ROOT}/logs/server.starting
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# Specify the script name so that it may be provided in command-line usage.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai KondrashovSCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=start-ds"
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# See if an "-N" or a "--nodetach" argument was provided as a command-line
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# argument. If it was, then don't use nohup to send to the background, and
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov# send all output to both the console and a lot file.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov echo $$ > "${PID_FILE}"
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov exec "${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov --configClass org.opends.server.extensions.ConfigFileHandler \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov nohup "${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov --configClass org.opends.server.extensions.ConfigFileHandler \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov --configFile "${CONFIG_FILE}" "${@}" > "${LOG_FILE}" 2>&1 &
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov echo $! > "${PID_FILE}"
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov "${JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov --targetFile "${STARTING_FILE}" --logFile "${LOG_FILE}"