start-ds revision 3978
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsync#!/bin/sh
e6b62bbfe72b2586784167aaa552426303ef444fvboxsync#
a169901884ca9d134cbfad013f290fa234c37aedvboxsync# CDDL HEADER START
a169901884ca9d134cbfad013f290fa234c37aedvboxsync#
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync# The contents of this file are subject to the terms of the
a169901884ca9d134cbfad013f290fa234c37aedvboxsync# Common Development and Distribution License, Version 1.0 only
a169901884ca9d134cbfad013f290fa234c37aedvboxsync# (the "License"). You may not use this file except in compliance
a169901884ca9d134cbfad013f290fa234c37aedvboxsync# with the License.
a169901884ca9d134cbfad013f290fa234c37aedvboxsync#
a169901884ca9d134cbfad013f290fa234c37aedvboxsync# You can obtain a copy of the license at
a169901884ca9d134cbfad013f290fa234c37aedvboxsync# trunk/opends/resource/legal-notices/OpenDS.LICENSE
a169901884ca9d134cbfad013f290fa234c37aedvboxsync# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
a169901884ca9d134cbfad013f290fa234c37aedvboxsync# See the License for the specific language governing permissions
a169901884ca9d134cbfad013f290fa234c37aedvboxsync# and limitations under the License.
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync#
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync# When distributing Covered Code, include this CDDL HEADER in each
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync# file and include the License file at
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
a169901884ca9d134cbfad013f290fa234c37aedvboxsync# add the following below this CDDL HEADER, with the fields enclosed
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsync# by brackets "[]" replaced with your own identifying information:
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsync# Portions Copyright [yyyy] [name of copyright owner]
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsync#
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsync# CDDL HEADER END
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsync#
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsync#
02487e3b759646add535e475e35311265235a629vboxsync# Copyright 2006-2008 Sun Microsystems, Inc.
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsync
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsync
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsync# Capture the current working directory so that we can change to it later.
02487e3b759646add535e475e35311265235a629vboxsync# Then capture the location of this script and the Directory Server instance
02487e3b759646add535e475e35311265235a629vboxsync# root so that we can use them to create appropriate paths.
02487e3b759646add535e475e35311265235a629vboxsyncWORKING_DIR=`pwd`
02487e3b759646add535e475e35311265235a629vboxsync
02487e3b759646add535e475e35311265235a629vboxsynccd "`dirname "${0}"`"
02487e3b759646add535e475e35311265235a629vboxsyncSCRIPT_DIR=`pwd`
02487e3b759646add535e475e35311265235a629vboxsync
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsynccd ..
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsyncINSTALL_ROOT=`pwd`
02487e3b759646add535e475e35311265235a629vboxsyncexport INSTALL_ROOT
02487e3b759646add535e475e35311265235a629vboxsync
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsynccd "${WORKING_DIR}"
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsync
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsync
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsync# Specify the script name so that it may be provided in command-line usage.
02487e3b759646add535e475e35311265235a629vboxsyncSCRIPT_NAME="start-ds"
02487e3b759646add535e475e35311265235a629vboxsyncexport SCRIPT_NAME
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsync
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsync# check for presence of lib/_svc-opends.sh file
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsync# If present, we should be on Solaris/OpenSolaris and use SMF to start
6e793fadebda53870ee54ac9dcdbe30d612f22b5vboxsync# OpenDS.
6e793fadebda53870ee54ac9dcdbe30d612f22b5vboxsync# Check --exec. If not present, start OpenDS from SMF
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsync
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsyncif test -f "${INSTALL_ROOT}/lib/_svc-opends.sh"
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsyncthen
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsync if [ "$1" = "--exec" ]
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsync then
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsync shift
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsync elif [ -z "$1" -o "$1" = "-L" -o "$1" = "-Q" -o "$1" = "-N" -o \
f09a9ba0e70c09ac2c9728909fbf45cb7f81195dvboxsync "$1" = "--nodetach" -o "$1" = "-useLastKnownGoodConfig" \
f09a9ba0e70c09ac2c9728909fbf45cb7f81195dvboxsync -o "$1" = "--quiet" ]
f09a9ba0e70c09ac2c9728909fbf45cb7f81195dvboxsync then
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsync# these options are only used when trying to start the server
88af31c3f3aa61861ef84a71d880714ce2765101vboxsync# In this case, start it through the service.
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsync exec /usr/sbin/svcadm enable -t svc:/network/ldap/server:opends
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsync fi
02487e3b759646add535e475e35311265235a629vboxsyncfi
02487e3b759646add535e475e35311265235a629vboxsync
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsync# Set environment variables
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsyncSCRIPT_UTIL_CMD=set-full-environment-and-test-java
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsyncexport SCRIPT_UTIL_CMD
02487e3b759646add535e475e35311265235a629vboxsyncCHECK_VERSION=yes
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsyncexport CHECK_VERSION
02487e3b759646add535e475e35311265235a629vboxsync. "${INSTALL_ROOT}/lib/_script-util.sh"
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsyncRETURN_CODE=$?
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsyncif test ${RETURN_CODE} -ne 0
02487e3b759646add535e475e35311265235a629vboxsyncthen
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsync exit ${RETURN_CODE}
84ff08359ff42a2fe02b790b4750fb63874611dfvboxsyncfi
84ff08359ff42a2fe02b790b4750fb63874611dfvboxsync
84ff08359ff42a2fe02b790b4750fb63874611dfvboxsync# Specify the locations of important files that may be used when the server
84ff08359ff42a2fe02b790b4750fb63874611dfvboxsync# is starting.
84ff08359ff42a2fe02b790b4750fb63874611dfvboxsyncCONFIG_FILE=${INSTANCE_ROOT}/config/config.ldif
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsyncPID_FILE=${INSTANCE_ROOT}/logs/server.pid
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsyncLOG_FILE=${INSTANCE_ROOT}/logs/server.out
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsyncSTARTING_FILE=${INSTANCE_ROOT}/logs/server.starting
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsync
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsync
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsync# See if the provided set of arguments were sufficient for us to be able to
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsync# start the server or perform the requested operation. An exit code of 99
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsync# means that it should be possible to start the server. An exit code of 98
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsync# means that the server is already running and we shouldn't try to start it.
02487e3b759646add535e475e35311265235a629vboxsync# An exit code of anything else means that we're not trying to start the server
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsync# and we can just exit with that exit code.
02487e3b759646add535e475e35311265235a629vboxsync${OPENDS_JAVA_BIN} ${SCRIPT_NAME_ARG} org.opends.server.core.DirectoryServer \
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsync --configClass org.opends.server.extensions.ConfigFileHandler \
6e793fadebda53870ee54ac9dcdbe30d612f22b5vboxsync --configFile "${CONFIG_FILE}" --checkStartability "${@}"
02487e3b759646add535e475e35311265235a629vboxsyncEC=${?}
6e793fadebda53870ee54ac9dcdbe30d612f22b5vboxsyncif test ${EC} -eq 99 -o ${EC} -eq 103
5bdb53763096bf16287f1362de1196e2d2acafdcvboxsyncthen
f9fc8c7343143818644af6caf51a2b2520b8b7a9vboxsync #
# run detach
#
touch "${STARTING_FILE}"
nohup "${OPENDS_JAVA_BIN}" ${OPENDS_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
"${OPENDS_JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
--targetFile "${STARTING_FILE}" --logFile "${LOG_FILE}"
else
"${OPENDS_JAVA_BIN}" -Xms8M -Xmx8M 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.
${OPENDS_JAVA_BIN} ${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 ${?}
else
if test ${EC} -eq 100
then
#
# run no detach
#
echo $$ > "${PID_FILE}"
rm -f "${LOG_FILE}"
exec "${OPENDS_JAVA_BIN}" ${OPENDS_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 "${OPENDS_JAVA_BIN}" ${OPENDS_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