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