start-ds revision 3590
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# CDDL HEADER START
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# The contents of this file are subject to the terms of the
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# Common Development and Distribution License, Version 1.0 only
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# (the "License"). You may not use this file except in compliance
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# with the License.
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# You can obtain a copy of the license at
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# trunk/opends/resource/legal-notices/OpenDS.LICENSE
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# See the License for the specific language governing permissions
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# and limitations under the License.
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# When distributing Covered Code, include this CDDL HEADER in each
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# file and include the License file at
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# add the following below this CDDL HEADER, with the fields enclosed
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# by brackets "[]" replaced with your own identifying information:
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# Portions Copyright [yyyy] [name of copyright owner]
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# CDDL HEADER END
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# Copyright 2006-2008 Sun Microsystems, Inc.
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# Capture the current working directory so that we can change to it later.
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# Then capture the location of this script and the Directory Server instance
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# root so that we can use them to create appropriate paths.
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienlecd "${WORKING_DIR}"
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# Specify the locations of important files that may be used when the server
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# is starting.
37f9df7d5b474a12668813f98992dceb7c7feacbChad KienleSTARTING_FILE=${INSTANCE_ROOT}/logs/server.starting
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# Specify the script name so that it may be provided in command-line usage.
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# Set environment variables
37f9df7d5b474a12668813f98992dceb7c7feacbChad KienleSCRIPT_UTIL_CMD=set-full-environment-and-test-java
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle. "${INSTANCE_ROOT}/lib/_script-util.sh"
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# See if the provided set of arguments were sufficient for us to be able to
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# start the server or perform the requested operation. An exit code of 99
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# means that it should be possible to start the server. An exit code of 98
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# means that the server is already running and we shouldn't try to start it.
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# An exit code of anything else means that we're not trying to start the server
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle# and we can just exit with that exit code.
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle${OPENDS_JAVA_BIN} ${SCRIPT_NAME_ARG} org.opends.server.core.DirectoryServer \
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle --configClass org.opends.server.extensions.ConfigFileHandler \
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle --configFile "${CONFIG_FILE}" --checkStartability "${@}"
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle # run detach
37c999796383567df3db1f9d2a09942d83d413caChad Kienle nohup "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} \
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle --configClass org.opends.server.extensions.ConfigFileHandler \
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle --configFile "${CONFIG_FILE}" "${@}" > "${LOG_FILE}" 2>&1 &
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle echo $! > "${PID_FILE}"
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle "${OPENDS_JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle --targetFile "${STARTING_FILE}" --logFile "${LOG_FILE}"
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle "${OPENDS_JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle # An exit code of 98 means that the server is already running.
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle ${OPENDS_JAVA_BIN} ${SCRIPT_NAME_ARG} org.opends.server.core.DirectoryServer \
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle --configClass org.opends.server.extensions.ConfigFileHandler \
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle --configFile "${CONFIG_FILE}" --checkStartability > /dev/null 2>&1
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle # Could not start the server
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle # run no detach
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle echo $$ > "${PID_FILE}"
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle exec "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} \
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle --configClass org.opends.server.extensions.ConfigFileHandler \
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle # run no detach quiet
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle echo $$ > "${PID_FILE}"
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle exec "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} \
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle --configClass org.opends.server.extensions.ConfigFileHandler \
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle --configFile "${CONFIG_FILE}" "${@}" > /dev/null
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle # an error or the server is already started. Just return the code provided
37f9df7d5b474a12668813f98992dceb7c7feacbChad Kienle # by checkstartability