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