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