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