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