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