start-ds revision 2402
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj# CDDL HEADER START
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj# The contents of this file are subject to the terms of the
9a93784d34c322d1996e8a7b794a75230eac81a4wrowe# Common Development and Distribution License, Version 1.0 only
9a93784d34c322d1996e8a7b794a75230eac81a4wrowe# (the "License"). You may not use this file except in compliance
4bc630d510cef730e37b9207e145267f473b4471striker# with the License.
dba571e5c5a2586c7e2b382789f3250136ff7577jwoolley# You can obtain a copy of the license at
dba571e5c5a2586c7e2b382789f3250136ff7577jwoolley# trunk/opends/resource/legal-notices/OpenDS.LICENSE
07847078a10fe4e9229cc08adda5f421cafc0665jwoolley# See the License for the specific language governing permissions
0bd0176ce9f4321eeb506aa372d0bcc84befbf4cstriker# and limitations under the License.
c25203fdca093d4504c51b4cd974ff60d5aa4fb1wrowe# When distributing Covered Code, include this CDDL HEADER in each
c25203fdca093d4504c51b4cd974ff60d5aa4fb1wrowe# file and include the License file at
c25203fdca093d4504c51b4cd974ff60d5aa4fb1wrowe# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
d89c116f82699294ca744125723651c554bc5925wrowe# add the following below this CDDL HEADER, with the fields enclosed
4214e98fc9045e5010e66f9a967bd6d68f40d342aaron# by brackets "[]" replaced with your own identifying information:
8721697e2aece27b0e738519329f7976c72b27bfjerenkrantz# Portions Copyright [yyyy] [name of copyright owner]
91cacb801f6c0215b38322f6d2fc58cbfedfecfbjerenkrantz# CDDL HEADER END
df14f0d3a5191cdd7c4bb5b03acd135d43a6f51brbb# Portions Copyright 2006-2007 Sun Microsystems, Inc.
571760de5e60c0b459cb11be45507b923cd023eejwoolley# Capture the current working directory so that we can change to it later.
9180a5933673ffb1af633c255ceee029340f3b1erbb# Then capture the location of this script and the Directory Server instance
bcb6e1be6041dfeb549c8ea8d37f97ad4e90a0c3rbb# root so that we can use them to create appropriate paths.
8dd4618c4709236b4ea297d7250d282e463ce2d8rbbcd "${WORKING_DIR}"
bd929c73ef04789b7183b840d8db6e01d03a4d86rbb# See if JAVA_HOME is set. If not, then see if there is a java executable in
70f6f32765cfaadd6da8de6f0fea97ddd72d8fadmanoj# the path and try to figure it out.
2a6c49cfaef5979a5a06098f3ce987cd76769409manojif test -z "${JAVA_BIN}"
af4c982a7cf4515f124935f99a329744035fc699slive if test -z "${JAVA_HOME}"
af4c982a7cf4515f124935f99a329744035fc699slive if test -f "${INSTANCE_ROOT}/lib/set-java-home"
af4c982a7cf4515f124935f99a329744035fc699slive . "${INSTANCE_ROOT}/lib/set-java-home"
5ca8e11fadb6f7a8d9d0367c1800205c99d4bcd6jerenkrantz echo "ERROR: No Java installation could be found. Please set"
45b0e1c775c1cfed6473c9e5304179ccb9609f53stoddard echo " JAVA_HOME to the root of a Java 5.0 or higher"
dbec4658981e4f9127e8676457c28d42932be7cdtrawick echo " installation."
418f39e60a288f855ec033b566744489c3bbbf39trawick# Explicitly set the PATH, LD_LIBRARY_PATH, LD_PRELOAD, and other important
cc22a72861c58dda7f3768613aec864e4c4e0353striker# system environment variables for security and compatibility reasons.
b3b4e853e4958357ee2d50e2fe41effecfde9eedwroweexport PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 \
93f189f1198f539d3cfa75a15b23dcde60ee35ffrbb# Configure the appropriate CLASSPATH.
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz# Specify the locations of important files that may be used when the server
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz# is starting.
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantzSTARTING_FILE=${INSTANCE_ROOT}/logs/server.starting
1af5c0e25a649bb298e25ddfa5418fa18bdcb107aaron# Specify the script name so that it may be provided in command-line usage.
82455c2e3b6991846fbcbf0c9e41f57dbc681217brianpSCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=start-ds"
1b3f48fd6b1ccb8745f908e40156c5a85ca3c347jerenkrantz# Test that the provided JDK is 1.5 compatible.
b05930e6008f69bd323abe0c10f81f40ffd27983brianpif test -z "${JAVA_ARGS}"
f610c7c704235bc327dbe9b62982f5b3f8e30a77wrowe "${JAVA_BIN}" org.opends.server.tools.InstallDS -t 2> /dev/null
f610c7c704235bc327dbe9b62982f5b3f8e30a77wrowe echo "ERROR: The detected Java version could not be used. Please ensure"
b3b4e853e4958357ee2d50e2fe41effecfde9eedwrowe echo " that JAVA_HOME is set to the root of a valid Java 5.0 or"
f610c7c704235bc327dbe9b62982f5b3f8e30a77wrowe echo " higher installation."
f610c7c704235bc327dbe9b62982f5b3f8e30a77wrowe "${JAVA_BIN}" ${JAVA_ARGS} org.opends.server.tools.InstallDS -t 2> /dev/null
f610c7c704235bc327dbe9b62982f5b3f8e30a77wrowe echo "ERROR: The detected Java version could not be used with the"
f610c7c704235bc327dbe9b62982f5b3f8e30a77wrowe echo " set of arguments. Please ensure that JAVA_HOME is set to"
f610c7c704235bc327dbe9b62982f5b3f8e30a77wrowe echo " the root of a valid Java 5.0 or higher installation, and"
f610c7c704235bc327dbe9b62982f5b3f8e30a77wrowe echo " make sure that JAVA_ARGS contains a valid set of arguments"
f610c7c704235bc327dbe9b62982f5b3f8e30a77wrowe echo " for that JVM."
630f5fc1277582643fe0f831a4830e15127bd047jwoolley# See if the provided set of arguments were sufficient for us to be able to
f610c7c704235bc327dbe9b62982f5b3f8e30a77wrowe# start the server or perform the requested operation. An exit code of 99
f610c7c704235bc327dbe9b62982f5b3f8e30a77wrowe# means that it should be possible to start the server. An exit code of 98
f610c7c704235bc327dbe9b62982f5b3f8e30a77wrowe# means that the server is already running and we shouldn't try to start it.
f610c7c704235bc327dbe9b62982f5b3f8e30a77wrowe# An exit code of anything else means that we're not trying to start the server
56b2562cb4041a21bc313fde3204beabdb758800jwoolley# and we can just exit with that exit code.
56b2562cb4041a21bc313fde3204beabdb758800jwoolley${JAVA_BIN} ${SCRIPT_NAME_ARG} org.opends.server.core.DirectoryServer \
56b2562cb4041a21bc313fde3204beabdb758800jwoolley --configClass org.opends.server.extensions.ConfigFileHandler \
56b2562cb4041a21bc313fde3204beabdb758800jwoolley --configFile "${CONFIG_FILE}" --checkStartability "${@}"
f881b8be216de36c6b964324c772450bca38a4e6trawick # run detach
f881b8be216de36c6b964324c772450bca38a4e6trawick nohup "${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
56b2562cb4041a21bc313fde3204beabdb758800jwoolley --configClass org.opends.server.extensions.ConfigFileHandler \
b05930e6008f69bd323abe0c10f81f40ffd27983brianp --configFile "${CONFIG_FILE}" "${@}" > "${LOG_FILE}" 2>&1 &
b05930e6008f69bd323abe0c10f81f40ffd27983brianp echo $! > "${PID_FILE}"
b05930e6008f69bd323abe0c10f81f40ffd27983brianp "${JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
4c7dab038d90d7feb67ef8ddbfacc77be8c9dbf0jwoolley --targetFile "${STARTING_FILE}" --logFile "${LOG_FILE}"
4c7dab038d90d7feb67ef8ddbfacc77be8c9dbf0jwoolley "${JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
f9b8e29cfca92cf0a996e8ab17fa1a1f447cecc7stoddard # An exit code of 98 means that the server is already running.
f9b8e29cfca92cf0a996e8ab17fa1a1f447cecc7stoddard ${JAVA_BIN} ${SCRIPT_NAME_ARG} org.opends.server.core.DirectoryServer \
f9b8e29cfca92cf0a996e8ab17fa1a1f447cecc7stoddard --configClass org.opends.server.extensions.ConfigFileHandler \
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe # Could not start the server
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe # run no detach
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe echo $$ > "${PID_FILE}"
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe --configClass org.opends.server.extensions.ConfigFileHandler \
638a9edaf48cf003cd40ac25ee8c25f572107414stoddard # an error or the server is already started. Just return the code provided
638a9edaf48cf003cd40ac25ee8c25f572107414stoddard # by checkstartability