start-ds revision 44a7ec1a853804826c90cda2fbb4ac712c86bbaa
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe#!/bin/sh
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe#
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# CDDL HEADER START
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe#
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# The contents of this file are subject to the terms of the
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# Common Development and Distribution License, Version 1.0 only
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# (the "License"). You may not use this file except in compliance
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# with the License.
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe#
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# You can obtain a copy of the license at
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# trunk/opends/resource/legal-notices/OpenDS.LICENSE
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# See the License for the specific language governing permissions
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# and limitations under the License.
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe#
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# When distributing Covered Code, include this CDDL HEADER in each
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# file and include the License file at
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# add the following below this CDDL HEADER, with the fields enclosed
f71f7a61dec7c9089378d14493ad564a1dedf0b5neil_a_wilson# by brackets "[]" replaced with your own identifying information:
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# Portions Copyright [yyyy] [name of copyright owner]
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe#
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe# CDDL HEADER END
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe#
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe#
a3d3ab94806056d2355afea6fe8daac41059b9fbludovicp# Copyright 2006-2008 Sun Microsystems, Inc.
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson# Capture the current working directory so that we can change to it later.
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson# Then capture the location of this script and the Directory Server instance
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson# root so that we can use them to create appropriate paths.
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilsonWORKING_DIR=`pwd`
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson
3cedecd5ea21cca5d9709abf320a2082cd3694e5jvergaracd "`dirname "${0}"`"
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilsonSCRIPT_DIR=`pwd`
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilsoncd ..
014019918f7e3844f558f6159b8d41517254edc2lutoffINSTALL_ROOT=`pwd`
014019918f7e3844f558f6159b8d41517254edc2lutoffexport INSTALL_ROOT
014019918f7e3844f558f6159b8d41517254edc2lutoff
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilsoncd "${WORKING_DIR}"
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe
266c5071a91fda6a5159b08ea8d45261228d03d5neil_a_wilson# Specify the script name so that it may be provided in command-line usage.
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergaraSCRIPT_NAME="start-ds"
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergaraexport SCRIPT_NAME
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara
44a7ec1a853804826c90cda2fbb4ac712c86bbaaludovicp# check for presence of lib/_svc-opends.sh file
44a7ec1a853804826c90cda2fbb4ac712c86bbaaludovicp# If present, we should be on Solaris/OpenSolaris and use SMF to start
44a7ec1a853804826c90cda2fbb4ac712c86bbaaludovicp# OpenDS.
44a7ec1a853804826c90cda2fbb4ac712c86bbaaludovicp# Check --exec. If not present, start OpenDS from SMF
44a7ec1a853804826c90cda2fbb4ac712c86bbaaludovicp
44a7ec1a853804826c90cda2fbb4ac712c86bbaaludovicpif test -f "${INSTALL_ROOT}/lib/_svc-opends.sh"
44a7ec1a853804826c90cda2fbb4ac712c86bbaaludovicpthen
44a7ec1a853804826c90cda2fbb4ac712c86bbaaludovicp if [ "$1" == "--exec" ]
44a7ec1a853804826c90cda2fbb4ac712c86bbaaludovicp then
44a7ec1a853804826c90cda2fbb4ac712c86bbaaludovicp shift
44a7ec1a853804826c90cda2fbb4ac712c86bbaaludovicp elif [ -z "$1" -o "$1" == "-L" -o "$1" == "-Q" -o "$1" == "-N" -o \
44a7ec1a853804826c90cda2fbb4ac712c86bbaaludovicp "$1" == "--nodetach" -o "$1" == "-useLastKnownGoodConfig" \
44a7ec1a853804826c90cda2fbb4ac712c86bbaaludovicp -o "$1" == "--quiet" ]
44a7ec1a853804826c90cda2fbb4ac712c86bbaaludovicp then
44a7ec1a853804826c90cda2fbb4ac712c86bbaaludovicp# these options are only used when trying to start the server
44a7ec1a853804826c90cda2fbb4ac712c86bbaaludovicp# In this case, start it through the service.
44a7ec1a853804826c90cda2fbb4ac712c86bbaaludovicp exec /usr/sbin/svcadm enable -t svc:/network/ldap/server:opends
44a7ec1a853804826c90cda2fbb4ac712c86bbaaludovicp fi
44a7ec1a853804826c90cda2fbb4ac712c86bbaaludovicpfi
44a7ec1a853804826c90cda2fbb4ac712c86bbaaludovicp
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara# Set environment variables
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergaraSCRIPT_UTIL_CMD=set-full-environment-and-test-java
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergaraexport SCRIPT_UTIL_CMD
d319724fed3be916a9f68676aac6eb203d44b551chebrardCHECK_VERSION=yes
d319724fed3be916a9f68676aac6eb203d44b551chebrardexport CHECK_VERSION
014019918f7e3844f558f6159b8d41517254edc2lutoff. "${INSTALL_ROOT}/lib/_script-util.sh"
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergaraRETURN_CODE=$?
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergaraif test ${RETURN_CODE} -ne 0
39e085accf228684b9573bc8ad707a364ed6242ejvergarathen
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara exit ${RETURN_CODE}
39e085accf228684b9573bc8ad707a364ed6242ejvergarafi
266c5071a91fda6a5159b08ea8d45261228d03d5neil_a_wilson
d319724fed3be916a9f68676aac6eb203d44b551chebrard# Specify the locations of important files that may be used when the server
d319724fed3be916a9f68676aac6eb203d44b551chebrard# is starting.
d319724fed3be916a9f68676aac6eb203d44b551chebrardCONFIG_FILE=${INSTANCE_ROOT}/config/config.ldif
d319724fed3be916a9f68676aac6eb203d44b551chebrardPID_FILE=${INSTANCE_ROOT}/logs/server.pid
d319724fed3be916a9f68676aac6eb203d44b551chebrardLOG_FILE=${INSTANCE_ROOT}/logs/server.out
d319724fed3be916a9f68676aac6eb203d44b551chebrardSTARTING_FILE=${INSTANCE_ROOT}/logs/server.starting
d319724fed3be916a9f68676aac6eb203d44b551chebrard
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara
5c6cfc2988a5121fd22081643ef0790e38c99379neil_a_wilson# See if the provided set of arguments were sufficient for us to be able to
5c6cfc2988a5121fd22081643ef0790e38c99379neil_a_wilson# start the server or perform the requested operation. An exit code of 99
5c6cfc2988a5121fd22081643ef0790e38c99379neil_a_wilson# means that it should be possible to start the server. An exit code of 98
5c6cfc2988a5121fd22081643ef0790e38c99379neil_a_wilson# means that the server is already running and we shouldn't try to start it.
5c6cfc2988a5121fd22081643ef0790e38c99379neil_a_wilson# An exit code of anything else means that we're not trying to start the server
5c6cfc2988a5121fd22081643ef0790e38c99379neil_a_wilson# and we can just exit with that exit code.
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara${OPENDS_JAVA_BIN} ${SCRIPT_NAME_ARG} org.opends.server.core.DirectoryServer \
5c6cfc2988a5121fd22081643ef0790e38c99379neil_a_wilson --configClass org.opends.server.extensions.ConfigFileHandler \
5c6cfc2988a5121fd22081643ef0790e38c99379neil_a_wilson --configFile "${CONFIG_FILE}" --checkStartability "${@}"
5c6cfc2988a5121fd22081643ef0790e38c99379neil_a_wilsonEC=${?}
61ae414d98d24ba4a72a905b07db9424353669f4neil_a_wilsonif test ${EC} -eq 99 -o ${EC} -eq 103
5c6cfc2988a5121fd22081643ef0790e38c99379neil_a_wilsonthen
7070667c2dffad87009999bdeb16d5305e0afdbejvergara #
7070667c2dffad87009999bdeb16d5305e0afdbejvergara # run detach
7070667c2dffad87009999bdeb16d5305e0afdbejvergara #
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe touch "${STARTING_FILE}"
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara nohup "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} \
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe org.opends.server.core.DirectoryServer \
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe --configClass org.opends.server.extensions.ConfigFileHandler \
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe --configFile "${CONFIG_FILE}" "${@}" > "${LOG_FILE}" 2>&1 &
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe echo $! > "${PID_FILE}"
61ae414d98d24ba4a72a905b07db9424353669f4neil_a_wilson if test ${EC} -eq 99
61ae414d98d24ba4a72a905b07db9424353669f4neil_a_wilson then
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara "${OPENDS_JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
61ae414d98d24ba4a72a905b07db9424353669f4neil_a_wilson --targetFile "${STARTING_FILE}" --logFile "${LOG_FILE}"
61ae414d98d24ba4a72a905b07db9424353669f4neil_a_wilson else
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara "${OPENDS_JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
61ae414d98d24ba4a72a905b07db9424353669f4neil_a_wilson --targetFile "${STARTING_FILE}"
61ae414d98d24ba4a72a905b07db9424353669f4neil_a_wilson fi
fbae67e0ce2395d66b4cec5b17c54ddf8dd3dcb2jvergara EC=${?}
fbae67e0ce2395d66b4cec5b17c54ddf8dd3dcb2jvergara if test ${EC} -eq 0
fbae67e0ce2395d66b4cec5b17c54ddf8dd3dcb2jvergara then
fbae67e0ce2395d66b4cec5b17c54ddf8dd3dcb2jvergara # An exit code of 98 means that the server is already running.
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara ${OPENDS_JAVA_BIN} ${SCRIPT_NAME_ARG} org.opends.server.core.DirectoryServer \
fbae67e0ce2395d66b4cec5b17c54ddf8dd3dcb2jvergara --configClass org.opends.server.extensions.ConfigFileHandler \
ca7fd1a989fecd15241ed293d67750c6049d06d2neil_a_wilson --configFile "${CONFIG_FILE}" --checkStartability > /dev/null 2>&1
fbae67e0ce2395d66b4cec5b17c54ddf8dd3dcb2jvergara EC=${?}
fbae67e0ce2395d66b4cec5b17c54ddf8dd3dcb2jvergara if test ${EC} -eq 98
fbae67e0ce2395d66b4cec5b17c54ddf8dd3dcb2jvergara then
fbae67e0ce2395d66b4cec5b17c54ddf8dd3dcb2jvergara exit 0
fbae67e0ce2395d66b4cec5b17c54ddf8dd3dcb2jvergara else
fbae67e0ce2395d66b4cec5b17c54ddf8dd3dcb2jvergara # Could not start the server
fbae67e0ce2395d66b4cec5b17c54ddf8dd3dcb2jvergara exit 1
fbae67e0ce2395d66b4cec5b17c54ddf8dd3dcb2jvergara fi
fbae67e0ce2395d66b4cec5b17c54ddf8dd3dcb2jvergara fi
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe exit ${?}
7070667c2dffad87009999bdeb16d5305e0afdbejvergaraelse
7070667c2dffad87009999bdeb16d5305e0afdbejvergara if test ${EC} -eq 100
7070667c2dffad87009999bdeb16d5305e0afdbejvergara then
7070667c2dffad87009999bdeb16d5305e0afdbejvergara #
7070667c2dffad87009999bdeb16d5305e0afdbejvergara # run no detach
7070667c2dffad87009999bdeb16d5305e0afdbejvergara #
7070667c2dffad87009999bdeb16d5305e0afdbejvergara echo $$ > "${PID_FILE}"
4afc3f189bd46ee59828c326a83684969dc39d80neil_a_wilson rm -f "${LOG_FILE}"
27f8adec83293fb8bd3bfa37175322b0ee3bb933jvergara exec "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} \
7070667c2dffad87009999bdeb16d5305e0afdbejvergara org.opends.server.core.DirectoryServer \
7070667c2dffad87009999bdeb16d5305e0afdbejvergara --configClass org.opends.server.extensions.ConfigFileHandler \
7070667c2dffad87009999bdeb16d5305e0afdbejvergara --configFile "${CONFIG_FILE}" "${@}"
61491a8f67f7eae3967ce28737730583c6ad922djvergara elif test ${EC} -eq 104
61491a8f67f7eae3967ce28737730583c6ad922djvergara then
61491a8f67f7eae3967ce28737730583c6ad922djvergara #
61491a8f67f7eae3967ce28737730583c6ad922djvergara # run no detach quiet
61491a8f67f7eae3967ce28737730583c6ad922djvergara #
61491a8f67f7eae3967ce28737730583c6ad922djvergara echo $$ > "${PID_FILE}"
61491a8f67f7eae3967ce28737730583c6ad922djvergara rm -f "${LOG_FILE}"
61491a8f67f7eae3967ce28737730583c6ad922djvergara exec "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} \
61491a8f67f7eae3967ce28737730583c6ad922djvergara org.opends.server.core.DirectoryServer \
61491a8f67f7eae3967ce28737730583c6ad922djvergara --configClass org.opends.server.extensions.ConfigFileHandler \
61491a8f67f7eae3967ce28737730583c6ad922djvergara --configFile "${CONFIG_FILE}" "${@}" > /dev/null
7070667c2dffad87009999bdeb16d5305e0afdbejvergara else
7070667c2dffad87009999bdeb16d5305e0afdbejvergara #
7070667c2dffad87009999bdeb16d5305e0afdbejvergara # an error or the server is already started. Just return the code provided
7070667c2dffad87009999bdeb16d5305e0afdbejvergara # by checkstartability
7070667c2dffad87009999bdeb16d5305e0afdbejvergara #
7070667c2dffad87009999bdeb16d5305e0afdbejvergara exit ${EC}
7070667c2dffad87009999bdeb16d5305e0afdbejvergara fi
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipefi