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