start-ds revision 486
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe#!/bin/sh
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe#
2ad080048d86cc499a05750422d99a4b54da9e6dwrowe# CDDL HEADER START
a601d863bd772fefc4dc82a883589d8be6a44811wrowe#
a601d863bd772fefc4dc82a883589d8be6a44811wrowe# The contents of this file are subject to the terms of the
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# Common Development and Distribution License, Version 1.0 only
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# (the "License"). You may not use this file except in compliance
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# with the License.
b96d47f210d6523eaa51543168f0ee910f19b227slive#
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# You can obtain a copy of the license at
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# trunk/opends/resource/legal-notices/OpenDS.LICENSE
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# See the License for the specific language governing permissions
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# and limitations under the License.
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe#
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# When distributing Covered Code, include this CDDL HEADER in each
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# file and include the License file at
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# add the following below this CDDL HEADER, with the fields enclosed
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# by brackets "[]" replaced with your own identifying * information:
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# Portions Copyright [yyyy] [name of copyright owner]
b96d47f210d6523eaa51543168f0ee910f19b227slive#
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# CDDL HEADER END
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe#
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe#
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# Portions Copyright 2006 Sun Microsystems, Inc.
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe
b96d47f210d6523eaa51543168f0ee910f19b227slive# See if JAVA_HOME is set. If not, then see if there is a java executable in
b96d47f210d6523eaa51543168f0ee910f19b227slive# the path and try to figure it out.
b96d47f210d6523eaa51543168f0ee910f19b227sliveif test -z "${JAVA_BIN}"
b96d47f210d6523eaa51543168f0ee910f19b227slivethen
b96d47f210d6523eaa51543168f0ee910f19b227slive if test -z "${JAVA_HOME}"
b96d47f210d6523eaa51543168f0ee910f19b227slive then
b96d47f210d6523eaa51543168f0ee910f19b227slive JAVA_BIN=`which java 2> /dev/null`
b96d47f210d6523eaa51543168f0ee910f19b227slive if test ${?} -eq 0
b96d47f210d6523eaa51543168f0ee910f19b227slive then
b96d47f210d6523eaa51543168f0ee910f19b227slive export JAVA_BIN
b96d47f210d6523eaa51543168f0ee910f19b227slive else
b96d47f210d6523eaa51543168f0ee910f19b227slive echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
b96d47f210d6523eaa51543168f0ee910f19b227slive exit 1
b96d47f210d6523eaa51543168f0ee910f19b227slive fi
b96d47f210d6523eaa51543168f0ee910f19b227slive else
b96d47f210d6523eaa51543168f0ee910f19b227slive JAVA_BIN=${JAVA_HOME}/bin/java
b96d47f210d6523eaa51543168f0ee910f19b227slive export JAVA_BIN
b96d47f210d6523eaa51543168f0ee910f19b227slive fi
b96d47f210d6523eaa51543168f0ee910f19b227slivefi
b96d47f210d6523eaa51543168f0ee910f19b227slive
b96d47f210d6523eaa51543168f0ee910f19b227slive
b96d47f210d6523eaa51543168f0ee910f19b227slive# Explicitly set the PATH, LD_LIBRARY_PATH, LD_PRELOAD, and other important
b96d47f210d6523eaa51543168f0ee910f19b227slive# system environment variables for security and compatibility reasons.
b96d47f210d6523eaa51543168f0ee910f19b227slivePATH=/bin:/usr/bin
b96d47f210d6523eaa51543168f0ee910f19b227sliveLD_LIBRARY_PATH=
b96d47f210d6523eaa51543168f0ee910f19b227sliveLD_LIBRARY_PATH_32=
b96d47f210d6523eaa51543168f0ee910f19b227sliveLD_LIBRARY_PATH_64=
b96d47f210d6523eaa51543168f0ee910f19b227sliveLD_PRELOAD=
b96d47f210d6523eaa51543168f0ee910f19b227sliveLD_PRELOAD_32=
b96d47f210d6523eaa51543168f0ee910f19b227sliveLD_PRELOAD_64=
b96d47f210d6523eaa51543168f0ee910f19b227sliveexport PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 \
b96d47f210d6523eaa51543168f0ee910f19b227slive LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_34
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe
b96d47f210d6523eaa51543168f0ee910f19b227slive# Capture the current working directory so that we can change to it later.
b96d47f210d6523eaa51543168f0ee910f19b227slive# Then capture the location of this script and the Directory Server instance
b96d47f210d6523eaa51543168f0ee910f19b227slive# root so that we can use them to create appropriate paths.
b96d47f210d6523eaa51543168f0ee910f19b227sliveWORKING_DIR=`pwd`
b96d47f210d6523eaa51543168f0ee910f19b227slive
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowecd `dirname "${0}"`
998d56ea74f8cc733b423da076dadb0fd0a789f3wroweSCRIPT_DIR=`pwd`
2ad080048d86cc499a05750422d99a4b54da9e6dwrowe
2ad080048d86cc499a05750422d99a4b54da9e6dwrowecd ..
998d56ea74f8cc733b423da076dadb0fd0a789f3wroweINSTANCE_ROOT=`pwd`
998d56ea74f8cc733b423da076dadb0fd0a789f3wroweexport INSTANCE_ROOT
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowecd "${WORKING_DIR}"
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# Configure the appropriate CLASSPATH.
998d56ea74f8cc733b423da076dadb0fd0a789f3wroweCLASSPATH=${INSTANCE_ROOT}/classes
b96d47f210d6523eaa51543168f0ee910f19b227slivefor JAR in ${INSTANCE_ROOT}/lib/*.jar
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowedo
b96d47f210d6523eaa51543168f0ee910f19b227slive CLASSPATH=${CLASSPATH}:${JAR}
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowedone
998d56ea74f8cc733b423da076dadb0fd0a789f3wroweexport CLASSPATH
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# Specify the locations of important files that may be used when the server
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# is starting.
998d56ea74f8cc733b423da076dadb0fd0a789f3wroweCONFIG_FILE=${INSTANCE_ROOT}/config/config.ldif
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowePID_FILE=${INSTANCE_ROOT}/logs/server.pid
998d56ea74f8cc733b423da076dadb0fd0a789f3wroweLOG_FILE=${INSTANCE_ROOT}/logs/server.out
998d56ea74f8cc733b423da076dadb0fd0a789f3wroweSTARTING_FILE=${INSTANCE_ROOT}/logs/server.starting
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# See if "-nodetach" was specified as the first command-line argument. If it
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# was, then don't use nohup to send to the background, and send all output to
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe# both the console and a log file.
998d56ea74f8cc733b423da076dadb0fd0a789f3wroweif test "${1}" = "-nodetach"
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowethen
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe shift
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe echo $$ > "${PID_FILE}"
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe rm -f "${PID_FILE}" "${LOG_FILE}"
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe exec "${JAVA_BIN}" ${JAVA_ARGS} \
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe org.opends.server.core.DirectoryServer \
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe --configClass org.opends.server.extensions.ConfigFileHandler \
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe --configFile "${CONFIG_FILE}" --noDetach "${@}"
998d56ea74f8cc733b423da076dadb0fd0a789f3wroweelse
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe touch "${STARTING_FILE}"
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe nohup "${JAVA_BIN}" ${JAVA_ARGS} \
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe org.opends.server.core.DirectoryServer \
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe --configClass org.opends.server.extensions.ConfigFileHandler \
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe --configFile "${CONFIG_FILE}" "${@}" > "${LOG_FILE}" 2>&1 &
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe echo $! > "${PID_FILE}"
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe "${JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe --targetFile "${STARTING_FILE}" --logFile "${LOG_FILE}"
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe exit ${?}
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowefi
998d56ea74f8cc733b423da076dadb0fd0a789f3wrowe