start-ds revision 1181
70N/A#!/bin/sh
70N/A#
1104N/A# CDDL HEADER START
70N/A#
70N/A# The contents of this file are subject to the terms of the
919N/A# Common Development and Distribution License, Version 1.0 only
919N/A# (the "License"). You may not use this file except in compliance
919N/A# with the License.
919N/A#
919N/A# You can obtain a copy of the license at
919N/A# trunk/opends/resource/legal-notices/OpenDS.LICENSE
919N/A# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
919N/A# See the License for the specific language governing permissions
919N/A# and limitations under the License.
919N/A#
919N/A# When distributing Covered Code, include this CDDL HEADER in each
919N/A# file and include the License file at
919N/A# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
919N/A# add the following below this CDDL HEADER, with the fields enclosed
919N/A# by brackets "[]" replaced with your own identifying information:
919N/A# Portions Copyright [yyyy] [name of copyright owner]
919N/A#
70N/A# CDDL HEADER END
70N/A#
70N/A#
70N/A# Portions Copyright 2006-2007 Sun Microsystems, Inc.
851N/A
851N/A
851N/A# Capture the current working directory so that we can change to it later.
851N/A# Then capture the location of this script and the Directory Server instance
851N/A# root so that we can use them to create appropriate paths.
98N/AWORKING_DIR=`pwd`
551N/A
321N/Acd `dirname "${0}"`
321N/ASCRIPT_DIR=`pwd`
550N/A
550N/Acd ..
213N/AINSTANCE_ROOT=`pwd`
649N/Aexport INSTANCE_ROOT
304N/A
530N/Acd "${WORKING_DIR}"
425N/A
425N/A
325N/A# See if JAVA_HOME is set. If not, then see if there is a java executable in
493N/A# the path and try to figure it out.
536N/Aif test -z "${JAVA_BIN}"
456N/Athen
320N/A if test -z "${JAVA_HOME}"
332N/A then
501N/A if test -f "${INSTANCE_ROOT}/bin/set-java-home"
231N/A then
550N/A . "${INSTANCE_ROOT}/bin/set-java-home"
347N/A JAVA_BIN="${JAVA_HOME}/bin/java"
532N/A export JAVA_BIN
463N/A else
493N/A JAVA_BIN=`which java 2> /dev/null`
425N/A if test ${?} -eq 0
493N/A then
791N/A export JAVA_BIN
472N/A else
324N/A echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
347N/A exit 1
310N/A fi
316N/A fi
474N/A else
290N/A JAVA_BIN="${JAVA_HOME}/bin/java"
332N/A export JAVA_BIN
464N/A fi
332N/Afi
509N/A
835N/A
835N/A# Explicitly set the PATH, LD_LIBRARY_PATH, LD_PRELOAD, and other important
332N/A# system environment variables for security and compatibility reasons.
210N/APATH=/bin:/usr/bin
493N/ALD_LIBRARY_PATH=
792N/ALD_LIBRARY_PATH_32=
128N/ALD_LIBRARY_PATH_64=
414N/ALD_PRELOAD=
484N/ALD_PRELOAD_32=
326N/ALD_PRELOAD_64=
493N/Aexport PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 \
335N/A LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_34
493N/A
493N/A
729N/A# Configure the appropriate CLASSPATH.
425N/ACLASSPATH=${INSTANCE_ROOT}/classes
370N/Afor JAR in ${INSTANCE_ROOT}/lib/*.jar
70N/Ado
400N/A CLASSPATH=${CLASSPATH}:${JAR}
294N/Adone
435N/Aexport CLASSPATH
800N/A
98N/A
434N/A# Specify the locations of important files that may be used when the server
505N/A# is starting.
277N/ACONFIG_FILE=${INSTANCE_ROOT}/config/config.ldif
433N/APID_FILE=${INSTANCE_ROOT}/logs/server.pid
546N/ALOG_FILE=${INSTANCE_ROOT}/logs/server.out
356N/ASTARTING_FILE=${INSTANCE_ROOT}/logs/server.starting
289N/A
326N/A
439N/A# Specify the script name so that it may be provided in command-line usage.
501N/ASCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=start-ds"
469N/Aexport SCRIPT_NAME_ARG
290N/A
542N/A# Test that the provided JDK is 1.5 compatible.
424N/Aif test -z "${JAVA_ARGS}"
286N/Athen
90N/A "${JAVA_BIN}" org.opends.server.tools.InstallDS -t 2> /dev/null
475N/A if test ${?} -ne 0
295N/A then
70N/A echo "ERROR: The detected Java version could not be used. Please set "
299N/A echo " JAVA_HOME to the root of a Java 5.0 installation."
262N/A exit 1
455N/A fi
539N/Aelse
277N/A "${JAVA_BIN}" ${JAVA_ARGS} org.opends.server.tools.InstallDS -t 2> /dev/null
332N/A if test ${?} -ne 0
332N/A then
493N/A echo "ERROR: The detected Java version could not be used with the specified"
70N/A echo "Java arguments. Please set JAVA_HOME to the root of a Java 5.0 installation."
70N/A exit 1
319N/A fi
280N/Afi
319N/A
70N/A# See if the provided set of arguments were sufficient for us to be able to
98N/A# start the server or perform the requested operation. An exit code of 99
98N/A# means that it should be possible to start the server. An exit code of 98
414N/A# means that the server is already running and we shouldn't try to start it.
98N/A# An exit code of anything else means that we're not trying to start the server
744N/A# and we can just exit with that exit code.
1104N/A${JAVA_BIN} ${SCRIPT_NAME_ARG} org.opends.server.core.DirectoryServer \
744N/A --configClass org.opends.server.extensions.ConfigFileHandler \
763N/A --configFile "${CONFIG_FILE}" --checkStartability "${@}"
763N/AEC=${?}
763N/Aif test ${EC} -eq 99
744N/Athen
493N/A #
967N/A # run detach
70N/A #
493N/A touch "${STARTING_FILE}"
493N/A nohup "${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
967N/A org.opends.server.core.DirectoryServer \
--configClass org.opends.server.extensions.ConfigFileHandler \
--configFile "${CONFIG_FILE}" "${@}" > "${LOG_FILE}" 2>&1 &
echo $! > "${PID_FILE}"
"${JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
--targetFile "${STARTING_FILE}" --logFile "${LOG_FILE}"
exit ${?}
else
if test ${EC} -eq 100
then
#
# run no detach
#
echo $$ > "${PID_FILE}"
rm -f "${LOG_FILE}"
exec "${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
org.opends.server.core.DirectoryServer \
--configClass org.opends.server.extensions.ConfigFileHandler \
--configFile "${CONFIG_FILE}" "${@}"
else
#
# an error or the server is already started. Just return the code provided
# by checkstartability
#
exit ${EC}
fi
fi