start-ds revision a3d3ab94806056d2355afea6fe8daac41059b9fb
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan#!/bin/sh
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan#
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# CDDL HEADER START
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan#
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# The contents of this file are subject to the terms of the
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# Common Development and Distribution License, Version 1.0 only
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# (the "License"). You may not use this file except in compliance
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# with the License.
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan#
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# You can obtain a copy of the license at
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# trunk/opends/resource/legal-notices/OpenDS.LICENSE
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# See the License for the specific language governing permissions
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# and limitations under the License.
923784d59ac065eee98b208dfacda6fbc24c71d6Jake Feasel#
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# When distributing Covered Code, include this CDDL HEADER in each
4eb529f0471672590d77cf89ef23987ba2c95ff4Laszlo Hordos# file and include the License file at
4eb529f0471672590d77cf89ef23987ba2c95ff4Laszlo Hordos# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# add the following below this CDDL HEADER, with the fields enclosed
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# by brackets "[]" replaced with your own identifying information:
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# Portions Copyright [yyyy] [name of copyright owner]
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan#
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# CDDL HEADER END
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan#
7c64421614d420f1951773af3ce6a6111cef84b2Jake Feasel#
7c64421614d420f1951773af3ce6a6111cef84b2Jake Feasel# Copyright 2006-2008 Sun Microsystems, Inc.
7c64421614d420f1951773af3ce6a6111cef84b2Jake Feasel
7c64421614d420f1951773af3ce6a6111cef84b2Jake Feasel
b564baaca75789be41eba24bb96e31f3ce5b10eeJake Feasel# Capture the current working directory so that we can change to it later.
7c64421614d420f1951773af3ce6a6111cef84b2Jake Feasel# Then capture the location of this script and the Directory Server instance
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan# root so that we can use them to create appropriate paths.
54f30b716553d88ea9ebb010037f4c74eb1d69acPaul BryanWORKING_DIR=`pwd`
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan
e5c203467ee4398ae81a6adb63da7477451b2e77Laszlo Hordoscd `dirname "${0}"`
e5c203467ee4398ae81a6adb63da7477451b2e77Laszlo HordosSCRIPT_DIR=`pwd`
8166b048bd3e2106dbdeaa1a2b8a728952d788f4Laszlo Hordos
8166b048bd3e2106dbdeaa1a2b8a728952d788f4Laszlo Hordoscd ..
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo HordosINSTANCE_ROOT=`pwd`
e5c203467ee4398ae81a6adb63da7477451b2e77Laszlo Hordosexport INSTANCE_ROOT
e5c203467ee4398ae81a6adb63da7477451b2e77Laszlo Hordos
e5c203467ee4398ae81a6adb63da7477451b2e77Laszlo Hordoscd "${WORKING_DIR}"
e5c203467ee4398ae81a6adb63da7477451b2e77Laszlo Hordos
e5c203467ee4398ae81a6adb63da7477451b2e77Laszlo Hordos# Specify the locations of important files that may be used when the server
e5c203467ee4398ae81a6adb63da7477451b2e77Laszlo Hordos# is starting.
e5c203467ee4398ae81a6adb63da7477451b2e77Laszlo HordosCONFIG_FILE=${INSTANCE_ROOT}/config/config.ldif
e5c203467ee4398ae81a6adb63da7477451b2e77Laszlo HordosPID_FILE=${INSTANCE_ROOT}/logs/server.pid
8166b048bd3e2106dbdeaa1a2b8a728952d788f4Laszlo HordosLOG_FILE=${INSTANCE_ROOT}/logs/server.out
e5c203467ee4398ae81a6adb63da7477451b2e77Laszlo HordosSTARTING_FILE=${INSTANCE_ROOT}/logs/server.starting
8166b048bd3e2106dbdeaa1a2b8a728952d788f4Laszlo Hordos
8166b048bd3e2106dbdeaa1a2b8a728952d788f4Laszlo Hordos
8166b048bd3e2106dbdeaa1a2b8a728952d788f4Laszlo Hordos# Specify the script name so that it may be provided in command-line usage.
8166b048bd3e2106dbdeaa1a2b8a728952d788f4Laszlo HordosSCRIPT_NAME="start-ds"
8166b048bd3e2106dbdeaa1a2b8a728952d788f4Laszlo Hordosexport SCRIPT_NAME
8166b048bd3e2106dbdeaa1a2b8a728952d788f4Laszlo Hordos
8166b048bd3e2106dbdeaa1a2b8a728952d788f4Laszlo Hordos# Set environment variables
8166b048bd3e2106dbdeaa1a2b8a728952d788f4Laszlo HordosSCRIPT_UTIL_CMD=set-full-environment-and-test-java
8166b048bd3e2106dbdeaa1a2b8a728952d788f4Laszlo Hordosexport SCRIPT_UTIL_CMD
8166b048bd3e2106dbdeaa1a2b8a728952d788f4Laszlo Hordos. "${INSTANCE_ROOT}/lib/_script-util.sh"
8166b048bd3e2106dbdeaa1a2b8a728952d788f4Laszlo HordosRETURN_CODE=$?
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryanif test ${RETURN_CODE} -ne 0
73bedec6a263fc6f6a15e58fb55eb1f2045b85a8Bruno Lavitthen
73bedec6a263fc6f6a15e58fb55eb1f2045b85a8Bruno Lavit exit ${RETURN_CODE}
73bedec6a263fc6f6a15e58fb55eb1f2045b85a8Bruno Lavitfi
73bedec6a263fc6f6a15e58fb55eb1f2045b85a8Bruno Lavit
73bedec6a263fc6f6a15e58fb55eb1f2045b85a8Bruno Lavit
73bedec6a263fc6f6a15e58fb55eb1f2045b85a8Bruno Lavit# See if the provided set of arguments were sufficient for us to be able to
73bedec6a263fc6f6a15e58fb55eb1f2045b85a8Bruno Lavit# start the server or perform the requested operation. An exit code of 99
73bedec6a263fc6f6a15e58fb55eb1f2045b85a8Bruno Lavit# means that it should be possible to start the server. An exit code of 98
a14db14686bf9f6817c47e5c14e887d74dd615f0Laszlo Hordos# means that the server is already running and we shouldn't try to start it.
13ec3d949d0a30c6d8fa0b899f583d64164f37f3Chris Drake# An exit code of anything else means that we're not trying to start the server
f85a185a657def022f6d8896cc755403f7d40694Andi Egloff# and we can just exit with that exit code.
a14db14686bf9f6817c47e5c14e887d74dd615f0Laszlo Hordos${OPENDS_JAVA_BIN} ${SCRIPT_NAME_ARG} org.opends.server.core.DirectoryServer \
2d7019e19039fd083850f76e54b6b26a7b06a8f2yaromin --configClass org.opends.server.extensions.ConfigFileHandler \
2d7019e19039fd083850f76e54b6b26a7b06a8f2yaromin --configFile "${CONFIG_FILE}" --checkStartability "${@}"
099518f7f744f2eaa4e23d3e0a92110f2e5e2811omeboldEC=${?}
2d7019e19039fd083850f76e54b6b26a7b06a8f2yarominif test ${EC} -eq 99 -o ${EC} -eq 103
00689490237ac7e37aa116d443e4e5882c5552dcMatthias Tristlthen
00689490237ac7e37aa116d443e4e5882c5552dcMatthias Tristl #
2d7019e19039fd083850f76e54b6b26a7b06a8f2yaromin # run detach
2d7019e19039fd083850f76e54b6b26a7b06a8f2yaromin #
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos touch "${STARTING_FILE}"
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel nohup "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} \
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos org.opends.server.core.DirectoryServer \
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos --configClass org.opends.server.extensions.ConfigFileHandler \
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos --configFile "${CONFIG_FILE}" "${@}" > "${LOG_FILE}" 2>&1 &
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos echo $! > "${PID_FILE}"
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos if test ${EC} -eq 99
8698e80519313c98c8d5c6de06ae04cdfc816cafMatthias Tristl then
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel "${OPENDS_JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos --targetFile "${STARTING_FILE}" --logFile "${LOG_FILE}"
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos else
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel "${OPENDS_JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel --targetFile "${STARTING_FILE}"
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel fi
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel EC=${?}
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel if test ${EC} -eq 0
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel then
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel # An exit code of 98 means that the server is already running.
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel ${OPENDS_JAVA_BIN} ${SCRIPT_NAME_ARG} org.opends.server.core.DirectoryServer \
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos --configClass org.opends.server.extensions.ConfigFileHandler \
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos --configFile "${CONFIG_FILE}" --checkStartability > /dev/null 2>&1
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos EC=${?}
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos if test ${EC} -eq 98
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos then
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos exit 0
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos else
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos # Could not start the server
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos exit 1
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos fi
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos fi
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos exit ${?}
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordoselse
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos if test ${EC} -eq 100
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel then
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel #
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel # run no detach
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel #
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos echo $$ > "${PID_FILE}"
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos rm -f "${LOG_FILE}"
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel exec "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} \
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel org.opends.server.core.DirectoryServer \
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel --configClass org.opends.server.extensions.ConfigFileHandler \
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel --configFile "${CONFIG_FILE}" "${@}"
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel else
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel #
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel # an error or the server is already started. Just return the code provided
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos # by checkstartability
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos #
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos exit ${EC}
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos fi
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordosfi
660a40ad15749d74efa0dd4ef12cb8781c570e22Laszlo Hordos