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