start-ds revision 2650
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmiller# CDDL HEADER START
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmiller# The contents of this file are subject to the terms of the
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmiller# Common Development and Distribution License, Version 1.0 only
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmiller# (the "License"). You may not use this file except in compliance
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmiller# with the License.
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmiller# You can obtain a copy of the license at
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmiller# trunk/opends/resource/legal-notices/OpenDS.LICENSE
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmiller# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmiller# See the License for the specific language governing permissions
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmiller# and limitations under the License.
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmiller# When distributing Covered Code, include this CDDL HEADER in each
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmiller# file and include the License file at
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmiller# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmiller# add the following below this CDDL HEADER, with the fields enclosed
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmiller# by brackets "[]" replaced with your own identifying information:
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmiller# Portions Copyright [yyyy] [name of copyright owner]
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmiller# CDDL HEADER END
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch# Portions Copyright 2006-2007 Sun Microsystems, Inc.
0f63005dc454e8131506be734dc0404f48c8578cJason Lemay# Capture the current working directory so that we can change to it later.
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch# Then capture the location of this script and the Directory Server instance
0f63005dc454e8131506be734dc0404f48c8578cJason Lemay# root so that we can use them to create appropriate paths.
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmillercd "${WORKING_DIR}"
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmiller# See if the environment variables are set. If not, then see if there is a java
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmiller# executable in the path and try to figure it out.
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branchif test -z "${OPENDS_JAVA_BIN}"
7f6887b5c5e1d621fbbb48d93b8ac940521d1e38Jason Lemay if test -z "${OPENDS_JAVA_HOME}"
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmiller if test -f "${INSTANCE_ROOT}/lib/set-java-home"
7f6887b5c5e1d621fbbb48d93b8ac940521d1e38Jason Lemay . "${INSTANCE_ROOT}/lib/set-java-home"
0f63005dc454e8131506be734dc0404f48c8578cJason Lemay if test -z "${JAVA_BIN}"
7f6887b5c5e1d621fbbb48d93b8ac940521d1e38Jason Lemay if test -z "${JAVA_HOME}"
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch echo "Please set OPENDS_JAVA_HOME to the root of a Java 5 (or later) installation."
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch# Explicitly set the PATH, LD_LIBRARY_PATH, LD_PRELOAD, and other important
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch# system environment variables for security and compatibility reasons.
dc357eedd51bb456915886c03247ac04d497ce2bJason Lemayexport PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 \
dc357eedd51bb456915886c03247ac04d497ce2bJason Lemay# Configure the appropriate CLASSPATH.
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch# Specify the locations of important files that may be used when the server
0f63005dc454e8131506be734dc0404f48c8578cJason Lemay# is starting.
dc357eedd51bb456915886c03247ac04d497ce2bJason LemaySTARTING_FILE=${INSTANCE_ROOT}/logs/server.starting
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch# Specify the script name so that it may be provided in command-line usage.
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan MmillerSCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=start-ds"
0f63005dc454e8131506be734dc0404f48c8578cJason Lemay# Test that the provided JDK is 1.5 compatible.
0f63005dc454e8131506be734dc0404f48c8578cJason Lemayif test -z "${JAVA_ARGS}"
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch "${OPENDS_JAVA_BIN}" org.opends.server.tools.InstallDS -t 2> /dev/null
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch echo "ERROR: The detected Java version could not be used. Please ensure"
0f63005dc454e8131506be734dc0404f48c8578cJason Lemay echo " that OPENDS_JAVA_HOME is set to the root of a valid Java 5.0 or"
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch echo " higher installation."
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch "${OPENDS_JAVA_BIN}" ${JAVA_ARGS} org.opends.server.tools.InstallDS -t 2> /dev/null
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch echo "ERROR: The detected Java version could not be used with the"
0f63005dc454e8131506be734dc0404f48c8578cJason Lemay echo " set of arguments. Please ensure that OPENDS_JAVA_HOME is"
0f63005dc454e8131506be734dc0404f48c8578cJason Lemay echo " set to the root of a valid Java 5.0 or higher installation, and"
0f63005dc454e8131506be734dc0404f48c8578cJason Lemay echo " make sure that JAVA_ARGS contains a valid set of arguments"
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch echo " for that JVM."
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch# See if the provided set of arguments were sufficient for us to be able to
0f63005dc454e8131506be734dc0404f48c8578cJason Lemay# start the server or perform the requested operation. An exit code of 99
0f63005dc454e8131506be734dc0404f48c8578cJason Lemay# means that it should be possible to start the server. An exit code of 98
0f63005dc454e8131506be734dc0404f48c8578cJason Lemay# means that the server is already running and we shouldn't try to start it.
0f63005dc454e8131506be734dc0404f48c8578cJason Lemay# An exit code of anything else means that we're not trying to start the server
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch# and we can just exit with that exit code.
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch${OPENDS_JAVA_BIN} ${SCRIPT_NAME_ARG} org.opends.server.core.DirectoryServer \
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch --configClass org.opends.server.extensions.ConfigFileHandler \
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch --configFile "${CONFIG_FILE}" --checkStartability "${@}"
0f63005dc454e8131506be734dc0404f48c8578cJason Lemay # run detach
0f63005dc454e8131506be734dc0404f48c8578cJason Lemay nohup "${OPENDS_JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
dc357eedd51bb456915886c03247ac04d497ce2bJason Lemay --configClass org.opends.server.extensions.ConfigFileHandler \
dc357eedd51bb456915886c03247ac04d497ce2bJason Lemay --configFile "${CONFIG_FILE}" "${@}" > "${LOG_FILE}" 2>&1 &
dc357eedd51bb456915886c03247ac04d497ce2bJason Lemay echo $! > "${PID_FILE}"
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch "${OPENDS_JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch --targetFile "${STARTING_FILE}" --logFile "${LOG_FILE}"
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch "${OPENDS_JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch # An exit code of 98 means that the server is already running.
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch ${OPENDS_JAVA_BIN} ${SCRIPT_NAME_ARG} org.opends.server.core.DirectoryServer \
7dcb2f62e25d05f2afeb4e79f10102350d7c2c7bBrendan Mmiller --configClass org.opends.server.extensions.ConfigFileHandler \
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch --configFile "${CONFIG_FILE}" --checkStartability > /dev/null 2>&1
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch # Could not start the server
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch # run no detach
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch echo $$ > "${PID_FILE}"
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch exec "${OPENDS_JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch --configClass org.opends.server.extensions.ConfigFileHandler \
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch # an error or the server is already started. Just return the code provided
548846fe158900a483ca91f47603c6bb6fde9b47Jon Branch # by checkstartability