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