start-ds revision 3978
98N/A#!/bin/sh
98N/A#
1447N/A# CDDL HEADER START
98N/A#
98N/A# The contents of this file are subject to the terms of the
919N/A# Common Development and Distribution License, Version 1.0 only
919N/A# (the "License"). You may not use this file except in compliance
919N/A# with the License.
919N/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#
98N/A# CDDL HEADER END
98N/A#
98N/A#
493N/A# Copyright 2006-2008 Sun Microsystems, Inc.
493N/A
98N/A
970N/A# Capture the current working directory so that we can change to it later.
970N/A# Then capture the location of this script and the Directory Server instance
970N/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`
1003N/A
1339N/Acd ..
1339N/AINSTALL_ROOT=`pwd`
970N/Aexport INSTALL_ROOT
970N/A
970N/Acd "${WORKING_DIR}"
970N/A
1366N/A
1366N/A# Specify the script name so that it may be provided in command-line usage.
970N/ASCRIPT_NAME="start-ds"
98N/Aexport SCRIPT_NAME
1366N/A
98N/A# check for presence of lib/_svc-opends.sh file
911N/A# If present, we should be on Solaris/OpenSolaris and use SMF to start
1366N/A# OpenDS.
1366N/A# Check --exec. If not present, start OpenDS from SMF
911N/A
98N/Aif test -f "${INSTALL_ROOT}/lib/_svc-opends.sh"
493N/Athen
493N/A if [ "$1" = "--exec" ]
98N/A then
98N/A shift
1089N/A elif [ -z "$1" -o "$1" = "-L" -o "$1" = "-Q" -o "$1" = "-N" -o \
156N/A "$1" = "--nodetach" -o "$1" = "-useLastKnownGoodConfig" \
493N/A -o "$1" = "--quiet" ]
493N/A then
493N/A# these options are only used when trying to start the server
493N/A# In this case, start it through the service.
493N/A exec /usr/sbin/svcadm enable -t svc:/network/ldap/server:opends
493N/A fi
98N/Afi
98N/A
98N/A# Set environment variables
1345N/ASCRIPT_UTIL_CMD=set-full-environment-and-test-java
1351N/Aexport SCRIPT_UTIL_CMD
1366N/ACHECK_VERSION=yes
606N/Aexport CHECK_VERSION
1422N/A. "${INSTALL_ROOT}/lib/_script-util.sh"
1422N/ARETURN_CODE=$?
1422N/Aif test ${RETURN_CODE} -ne 0
1422N/Athen
1422N/A exit ${RETURN_CODE}
1422N/Afi
606N/A
1351N/A# Specify the locations of important files that may be used when the server
606N/A# is starting.
606N/ACONFIG_FILE=${INSTANCE_ROOT}/config/config.ldif
606N/APID_FILE=${INSTANCE_ROOT}/logs/server.pid
1089N/ALOG_FILE=${INSTANCE_ROOT}/logs/server.out
1262N/ASTARTING_FILE=${INSTANCE_ROOT}/logs/server.starting
1265N/A
1265N/A
606N/A# See if the provided set of arguments were sufficient for us to be able to
1109N/A# start the server or perform the requested operation. An exit code of 99
1109N/A# means that it should be possible to start the server. An exit code of 98
1109N/A# means that the server is already running and we shouldn't try to start it.
606N/A# An exit code of anything else means that we're not trying to start the server
606N/A# and we can just exit with that exit code.
606N/A${OPENDS_JAVA_BIN} ${SCRIPT_NAME_ARG} org.opends.server.core.DirectoryServer \
98N/A --configClass org.opends.server.extensions.ConfigFileHandler \
1126N/A --configFile "${CONFIG_FILE}" --checkStartability "${@}"
1126N/AEC=${?}
1126N/Aif test ${EC} -eq 99 -o ${EC} -eq 103
970N/Athen
493N/A #
493N/A # run detach
493N/A #
98N/A touch "${STARTING_FILE}"
647N/A nohup "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} \
1089N/A org.opends.server.core.DirectoryServer \
1089N/A --configClass org.opends.server.extensions.ConfigFileHandler \
98N/A --configFile "${CONFIG_FILE}" "${@}" > "${LOG_FILE}" 2>&1 &
647N/A echo $! > "${PID_FILE}"
647N/A if test ${EC} -eq 99
1089N/A then
647N/A "${OPENDS_JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
1379N/A --targetFile "${STARTING_FILE}" --logFile "${LOG_FILE}"
1379N/A else
493N/A "${OPENDS_JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
493N/A --targetFile "${STARTING_FILE}"
98N/A fi
705N/A EC=${?}
705N/A if test ${EC} -eq 0
705N/A then
493N/A # An exit code of 98 means that the server is already running.
493N/A ${OPENDS_JAVA_BIN} ${SCRIPT_NAME_ARG} org.opends.server.core.DirectoryServer \
493N/A --configClass org.opends.server.extensions.ConfigFileHandler \
970N/A --configFile "${CONFIG_FILE}" --checkStartability > /dev/null 2>&1
1366N/A EC=${?}
970N/A if test ${EC} -eq 98
970N/A then
1351N/A exit 0
1366N/A else
1351N/A # Could not start the server
1366N/A exit 1
970N/A fi
970N/A fi
970N/A exit ${?}
970N/Aelse
970N/A if test ${EC} -eq 100
1366N/A then
970N/A #
970N/A # run no detach
1366N/A #
1366N/A echo $$ > "${PID_FILE}"
970N/A rm -f "${LOG_FILE}"
970N/A exec "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} \
970N/A org.opends.server.core.DirectoryServer \
970N/A --configClass org.opends.server.extensions.ConfigFileHandler \
970N/A --configFile "${CONFIG_FILE}" "${@}"
970N/A elif test ${EC} -eq 104
970N/A then
1366N/A #
970N/A # run no detach quiet
1366N/A #
1366N/A echo $$ > "${PID_FILE}"
970N/A rm -f "${LOG_FILE}"
1366N/A exec "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} \
970N/A org.opends.server.core.DirectoryServer \
970N/A --configClass org.opends.server.extensions.ConfigFileHandler \
970N/A --configFile "${CONFIG_FILE}" "${@}" > /dev/null
1366N/A else
1366N/A #
1366N/A # an error or the server is already started. Just return the code provided
970N/A # by checkstartability
1366N/A #
970N/A exit ${EC}
1366N/A fi
1366N/Afi
1366N/A