start-ds revision 2976
98N/A#!/bin/sh
98N/A#
98N/A# CDDL HEADER START
98N/A#
98N/A# The contents of this file are subject to the terms of the
98N/A# Common Development and Distribution License, Version 1.0 only
98N/A# (the "License"). You may not use this file except in compliance
98N/A# with the License.
98N/A#
98N/A# You can obtain a copy of the license at
98N/A# trunk/opends/resource/legal-notices/OpenDS.LICENSE
98N/A# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
98N/A# See the License for the specific language governing permissions
98N/A# and limitations under the License.
98N/A#
98N/A# When distributing Covered Code, include this CDDL HEADER in each
98N/A# file and include the License file at
98N/A# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
98N/A# add the following below this CDDL HEADER, with the fields enclosed
98N/A# by brackets "[]" replaced with your own identifying information:
98N/A# Portions Copyright [yyyy] [name of copyright owner]
98N/A#
98N/A# CDDL HEADER END
98N/A#
98N/A#
98N/A# Portions Copyright 2006-2007 Sun Microsystems, Inc.
98N/A
98N/A
98N/A# Capture the current working directory so that we can change to it later.
98N/A# Then capture the location of this script and the Directory Server instance
257N/A# root so that we can use them to create appropriate paths.
98N/AWORKING_DIR=`pwd`
98N/A
98N/Acd `dirname "${0}"`
156N/ASCRIPT_DIR=`pwd`
98N/A
98N/Acd ..
98N/AINSTANCE_ROOT=`pwd`
98N/Aexport INSTANCE_ROOT
98N/A
156N/Acd "${WORKING_DIR}"
98N/A
98N/A# Specify the locations of important files that may be used when the server
156N/A# is starting.
98N/ACONFIG_FILE=${INSTANCE_ROOT}/config/config.ldif
98N/APID_FILE=${INSTANCE_ROOT}/logs/server.pid
98N/ALOG_FILE=${INSTANCE_ROOT}/logs/server.out
98N/ASTARTING_FILE=${INSTANCE_ROOT}/logs/server.starting
98N/A
98N/A
98N/A# Specify the script name so that it may be provided in command-line usage.
98N/ASCRIPT_NAME="start-ds"
98N/Aexport SCRIPT_NAME
98N/A
98N/A# Set environment variables
98N/ASCRIPT_UTIL_CMD=set-full-environment-and-test-java
98N/Aexport SCRIPT_UTIL_CMD
98N/A. "${INSTANCE_ROOT}/lib/_script-util.sh"
98N/ARETURN_CODE=$?
98N/Aif test ${RETURN_CODE} -ne 0
98N/Athen
98N/A exit ${RETURN_CODE}
159N/Afi
98N/A
98N/A
98N/A# See if the provided set of arguments were sufficient for us to be able to
98N/A# start the server or perform the requested operation. An exit code of 99
98N/A# means that it should be possible to start the server. An exit code of 98
98N/A# means that the server is already running and we shouldn't try to start it.
98N/A# An exit code of anything else means that we're not trying to start the server
98N/A# and we can just exit with that exit code.
98N/A${OPENDS_JAVA_BIN} ${SCRIPT_NAME_ARG} org.opends.server.core.DirectoryServer \
98N/A --configClass org.opends.server.extensions.ConfigFileHandler \
199N/A --configFile "${CONFIG_FILE}" --checkStartability "${@}"
98N/AEC=${?}
98N/Aif test ${EC} -eq 99 -o ${EC} -eq 103
98N/Athen
98N/A #
257N/A # run detach
98N/A #
98N/A touch "${STARTING_FILE}"
98N/A nohup "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} \
98N/A org.opends.server.core.DirectoryServer \
98N/A --configClass org.opends.server.extensions.ConfigFileHandler \
98N/A --configFile "${CONFIG_FILE}" "${@}" > "${LOG_FILE}" 2>&1 &
98N/A echo $! > "${PID_FILE}"
98N/A if test ${EC} -eq 99
98N/A then
98N/A "${OPENDS_JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
98N/A --targetFile "${STARTING_FILE}" --logFile "${LOG_FILE}"
98N/A else
98N/A "${OPENDS_JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
98N/A --targetFile "${STARTING_FILE}"
98N/A fi
98N/A EC=${?}
156N/A if test ${EC} -eq 0
156N/A then
98N/A # An exit code of 98 means that the server is already running.
98N/A ${OPENDS_JAVA_BIN} ${SCRIPT_NAME_ARG} org.opends.server.core.DirectoryServer \
98N/A --configClass org.opends.server.extensions.ConfigFileHandler \
98N/A --configFile "${CONFIG_FILE}" --checkStartability > /dev/null 2>&1
98N/A EC=${?}
98N/A if test ${EC} -eq 98
98N/A then
98N/A exit 0
98N/A else
98N/A # Could not start the server
98N/A exit 1
98N/A fi
98N/A fi
98N/A exit ${?}
98N/Aelse
98N/A if test ${EC} -eq 100
98N/A then
98N/A #
98N/A # run no detach
98N/A #
98N/A echo $$ > "${PID_FILE}"
rm -f "${LOG_FILE}"
exec "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} \
org.opends.server.core.DirectoryServer \
--configClass org.opends.server.extensions.ConfigFileHandler \
--configFile "${CONFIG_FILE}" "${@}"
else
#
# an error or the server is already started. Just return the code provided
# by checkstartability
#
exit ${EC}
fi
fi