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