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