start-ds revision 4edb61f8b0f8ce9f62d803c706612376498672b4
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#!/bin/sh
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# CDDL HEADER START
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# The contents of this file are subject to the terms of the
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# Common Development and Distribution License, Version 1.0 only
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# (the "License"). You may not use this file except in compliance
d63de4508a08b11f57c307a15eda3cd95485bf2cvboxsync# with the License.
d63de4508a08b11f57c307a15eda3cd95485bf2cvboxsync#
d63de4508a08b11f57c307a15eda3cd95485bf2cvboxsync# You can obtain a copy of the license at
d63de4508a08b11f57c307a15eda3cd95485bf2cvboxsync# trunk/opends/resource/legal-notices/OpenDS.LICENSE
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# See the License for the specific language governing permissions
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# and limitations under the License.
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync#
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# When distributing Covered Code, include this CDDL HEADER in each
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# file and include the License file at
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# add the following below this CDDL HEADER, with the fields enclosed
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# by brackets "[]" replaced with your own identifying * information:
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# Portions Copyright [yyyy] [name of copyright owner]
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync#
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# CDDL HEADER END
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync#
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync#
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# Portions Copyright 2006 Sun Microsystems, Inc.
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# See if JAVA_HOME is set. If not, then see if there is a java executable in
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# the path and try to figure it out.
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsyncif test -z "${JAVA_BIN}"
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsyncthen
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync if test -z "${JAVA_HOME}"
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync then
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync JAVA_BIN=`which java 2> /dev/null`
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync if test ${?} -eq 0
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync then
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync export JAVA_BIN
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync else
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync exit 1
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync fi
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync else
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync JAVA_BIN=${JAVA_HOME}/bin/java
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync export JAVA_BIN
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync fi
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncfi
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# Explicitly set the PATH, LD_LIBRARY_PATH, LD_PRELOAD, and other important
cb172d105a87f41489b1553fbd99ec97932609ffvboxsync# system environment variables for security and compatibility reasons.
cb172d105a87f41489b1553fbd99ec97932609ffvboxsyncPATH=/bin:/usr/bin
cb172d105a87f41489b1553fbd99ec97932609ffvboxsyncLD_LIBRARY_PATH=
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncLD_LIBRARY_PATH_32=
6f6afebdc0972ac696b1199829d8a4c721a7218avboxsyncLD_LIBRARY_PATH_64=
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncLD_PRELOAD=
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsyncLD_PRELOAD_32=
2c691730ab202620fe427110841aa4e0075b7ccavboxsyncLD_PRELOAD_64=
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncexport PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 \
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_34
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# Capture the current working directory so that we can change to it later.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# Then capture the location of this script and the Directory Server instance
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# root so that we can use them to create appropriate paths.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncWORKING_DIR=`pwd`
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsynccd `dirname "${0}"`
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsyncSCRIPT_DIR=`pwd`
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsynccd ..
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncINSTANCE_ROOT=`pwd`
0700964a23df46033c8149ee10ce643cd3677061vboxsyncexport INSTANCE_ROOT
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsynccd "${WORKING_DIR}"
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# Configure the appropriate CLASSPATH.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncCLASSPATH=${INSTANCE_ROOT}/classes
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncfor JAR in ${INSTANCE_ROOT}/lib/*.jar
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncdo
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync CLASSPATH=${CLASSPATH}:${JAR}
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncdone
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncexport CLASSPATH
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
e42e8ed08e4b2bd2ebb1b160fea921788e1a54a5vboxsync# Specify the locations of important files that may be used when the server
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# is starting.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncCONFIG_FILE=${INSTANCE_ROOT}/config/config.ldif
0a987c833e0517dc4efefc14229d96dec62e0965vboxsyncPID_FILE=${INSTANCE_ROOT}/logs/server.pid
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncLOG_FILE=${INSTANCE_ROOT}/logs/server.out
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncSTARTING_FILE=${INSTANCE_ROOT}/logs/server.starting
cb172d105a87f41489b1553fbd99ec97932609ffvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# See if "-nodetach" was specified as the first command-line argument. If it
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# was, then don't use nohup to send to the background, and send all output to
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# both the console and a log file.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncif test "${1}" = "-nodetach"
4c07a936250bec9628653237718068d59914cdcevboxsyncthen
4c07a936250bec9628653237718068d59914cdcevboxsync shift
4c07a936250bec9628653237718068d59914cdcevboxsync echo $$ > "${PID_FILE}"
4c07a936250bec9628653237718068d59914cdcevboxsync rm -f "${PID_FILE}" "${LOG_FILE}"
4c07a936250bec9628653237718068d59914cdcevboxsync exec "${JAVA_BIN}" ${JAVA_ARGS} \
4c07a936250bec9628653237718068d59914cdcevboxsync org.opends.server.core.DirectoryServer \
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync --configClass org.opends.server.extensions.ConfigFileHandler \
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync --configFile "${CONFIG_FILE}" --noDetach "${@}"
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncelse
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync touch "${STARTING_FILE}"
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync nohup "${JAVA_BIN}" ${JAVA_ARGS} \
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync org.opends.server.core.DirectoryServer \
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync --configClass org.opends.server.extensions.ConfigFileHandler \
8632da57318dd02e08198ceb832c636dc7da6a30vboxsync --configFile "${CONFIG_FILE}" "${@}" > "${LOG_FILE}" 2>&1 &
8632da57318dd02e08198ceb832c636dc7da6a30vboxsync echo $! > "${PID_FILE}"
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync "${JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync --targetFile "${STARTING_FILE}" --logFile "${LOG_FILE}"
e361162aaa3f264085c651f9ea83f70d0ff3e431vboxsync exit ${?}
e361162aaa3f264085c651f9ea83f70d0ff3e431vboxsyncfi
e361162aaa3f264085c651f9ea83f70d0ff3e431vboxsync