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