start-ds revision 2976
f743002678eb67b99bbc29fee116b65d9530fec0wrowe#!/bin/sh
80833bb9a1bf25dcf19e814438a4b311d2e1f4cffuankg#
6736c640e65e06990ef33af71ee81fac4df4ff5fjim# CDDL HEADER START
b40bfdb714672f972887f9f1f1e154e00125bb68covener#
b40bfdb714672f972887f9f1f1e154e00125bb68covener# The contents of this file are subject to the terms of the
b40bfdb714672f972887f9f1f1e154e00125bb68covener# Common Development and Distribution License, Version 1.0 only
b40bfdb714672f972887f9f1f1e154e00125bb68covener# (the "License"). You may not use this file except in compliance
e6dd71992459d05a676b98b7963423dc5dc1e24aminfrin# with the License.
e6dd71992459d05a676b98b7963423dc5dc1e24aminfrin#
e6dd71992459d05a676b98b7963423dc5dc1e24aminfrin# You can obtain a copy of the license at
e6dd71992459d05a676b98b7963423dc5dc1e24aminfrin# trunk/opends/resource/legal-notices/OpenDS.LICENSE
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin# See the License for the specific language governing permissions
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin# and limitations under the License.
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin#
37a603727bdfb2a7d32b4283fcc3e524158b54b5jim# When distributing Covered Code, include this CDDL HEADER in each
37a603727bdfb2a7d32b4283fcc3e524158b54b5jim# file and include the License file at
f91e8c44b15a74bedaa027128a695950807e2968sf# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
f7e064c851d8258e74a9530738e985b3e0a29e18trawick# add the following below this CDDL HEADER, with the fields enclosed
acb0dcdb18c2593d9f5c01cb424b1dba2d372552niq# by brackets "[]" replaced with your own identifying information:
acb0dcdb18c2593d9f5c01cb424b1dba2d372552niq# Portions Copyright [yyyy] [name of copyright owner]
acb0dcdb18c2593d9f5c01cb424b1dba2d372552niq#
6249dfa569d3b4f1f539665b979a80c6e335d93etrawick# CDDL HEADER END
6249dfa569d3b4f1f539665b979a80c6e335d93etrawick#
0827cb14e550f6f65018431c22c2c913631c8f25kbrand#
6249dfa569d3b4f1f539665b979a80c6e335d93etrawick# Portions Copyright 2006-2007 Sun Microsystems, Inc.
ae600ca541efc686b34f8b1f21bd3d0741d37674covener
6249dfa569d3b4f1f539665b979a80c6e335d93etrawick
cfa64348224b66dd1c9979b809406c4d15b1c137fielding# Capture the current working directory so that we can change to it later.
74499a117b3b2cd9666715a14f90c0e5d1a4ee8ajim# Then capture the location of this script and the Directory Server instance
cfa64348224b66dd1c9979b809406c4d15b1c137fielding# root so that we can use them to create appropriate paths.
74499a117b3b2cd9666715a14f90c0e5d1a4ee8ajimWORKING_DIR=`pwd`
cfa64348224b66dd1c9979b809406c4d15b1c137fielding
74499a117b3b2cd9666715a14f90c0e5d1a4ee8ajimcd `dirname "${0}"`
cfa64348224b66dd1c9979b809406c4d15b1c137fieldingSCRIPT_DIR=`pwd`
74499a117b3b2cd9666715a14f90c0e5d1a4ee8ajim
cfa64348224b66dd1c9979b809406c4d15b1c137fieldingcd ..
INSTANCE_ROOT=`pwd`
export INSTANCE_ROOT
cd "${WORKING_DIR}"
# Specify the locations of important files that may be used when the server
# is starting.
CONFIG_FILE=${INSTANCE_ROOT}/config/config.ldif
PID_FILE=${INSTANCE_ROOT}/logs/server.pid
LOG_FILE=${INSTANCE_ROOT}/logs/server.out
STARTING_FILE=${INSTANCE_ROOT}/logs/server.starting
# Specify the script name so that it may be provided in command-line usage.
SCRIPT_NAME="start-ds"
export SCRIPT_NAME
# Set environment variables
SCRIPT_UTIL_CMD=set-full-environment-and-test-java
export SCRIPT_UTIL_CMD
. "${INSTANCE_ROOT}/lib/_script-util.sh"
RETURN_CODE=$?
if test ${RETURN_CODE} -ne 0
then
exit ${RETURN_CODE}
fi
# See if the provided set of arguments were sufficient for us to be able to
# start the server or perform the requested operation. An exit code of 99
# means that it should be possible to start the server. An exit code of 98
# means that the server is already running and we shouldn't try to start it.
# An exit code of anything else means that we're not trying to start the server
# and we can just exit with that exit code.
${OPENDS_JAVA_BIN} ${SCRIPT_NAME_ARG} org.opends.server.core.DirectoryServer \
--configClass org.opends.server.extensions.ConfigFileHandler \
--configFile "${CONFIG_FILE}" --checkStartability "${@}"
EC=${?}
if test ${EC} -eq 99 -o ${EC} -eq 103
then
#
# 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}" "${@}"
else
#
# an error or the server is already started. Just return the code provided
# by checkstartability
#
exit ${EC}
fi
fi