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