start-ds revision 4362
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync#!/bin/sh
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync#
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync# CDDL HEADER START
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync#
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync# The contents of this file are subject to the terms of the
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync# Common Development and Distribution License, Version 1.0 only
f5fc6d91e150cd61b1758c89b31d915270134385vboxsync# (the "License"). You may not use this file except in compliance
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync# with the License.
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync#
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync# You can obtain a copy of the license at
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync# trunk/opends/resource/legal-notices/OpenDS.LICENSE
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync# See the License for the specific language governing permissions
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync# and limitations under the License.
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync#
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync# When distributing Covered Code, include this CDDL HEADER in each
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync# file and include the License file at
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsync# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsync# add the following below this CDDL HEADER, with the fields enclosed
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsync# by brackets "[]" replaced with your own identifying information:
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync# Portions Copyright [yyyy] [name of copyright owner]
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsync#
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync# CDDL HEADER END
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsync#
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync#
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync# Copyright 2006-2009 Sun Microsystems, Inc.
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync# Capture the current working directory so that we can change to it later.
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync# Then capture the location of this script and the Directory Server instance
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync# root so that we can use them to create appropriate paths.
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsyncWORKING_DIR=`pwd`
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsynccd "`dirname "${0}"`"
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsyncSCRIPT_DIR=`pwd`
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsynccd ..
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsyncINSTALL_ROOT=`pwd`
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsyncexport INSTALL_ROOT
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsynccd "${WORKING_DIR}"
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsync
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync# Specify the script name so that it may be provided in command-line usage.
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsyncSCRIPT_NAME="start-ds"
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsyncexport SCRIPT_NAME
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync# check for presence of lib/_svc-opends.sh file
5a4d5e0a9fbeedae85826992b32e19a14fe4c01bvboxsync# If present, we should be on Solaris/OpenSolaris and use SMF to start
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync# OpenDS.
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync# Check --exec. If not present, start OpenDS from SMF
e91f2a55ed5a30342ec79ce273f3f4bad8283336vboxsync
40b7f0c2d3f97e0c6171f34f96ec3e05eea44d72vboxsyncif test -f "${INSTALL_ROOT}/lib/_svc-opends.sh"
ac2f8170e087931242786c8fe40ba16f457e18e0vboxsyncthen
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync if [ "$1" = "--exec" ]
78df3a3ca20e014e0d9eb72cd7bb72711255d5f6vboxsync then
e43535ace2499e7f8ef8822186047979bd58d464vboxsync shift
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync elif [ -z "$1" -o "$1" = "-L" -o "$1" = "-Q" -o "$1" = "-N" -o \
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync "$1" = "--nodetach" -o "$1" = "-useLastKnownGoodConfig" \
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync -o "$1" = "--quiet" ]
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync then
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync# these options are only used when trying to start the server
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync# In this case, start it through the service.
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync exec /usr/sbin/svcadm enable -t svc:/network/ldap/server:opends
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync fi
a7aa94e0115a73841f34ebbfa00f63fa1904e51fvboxsyncfi
b6cc138b99f86c2d29ecfe32cecf9f68ba5e73afvboxsync
0e5731ab59b4ecead38375f26eeea698f00b19fdvboxsync# Set environment variables
0e5731ab59b4ecead38375f26eeea698f00b19fdvboxsyncSCRIPT_UTIL_CMD=set-full-environment-and-test-java
0e5731ab59b4ecead38375f26eeea698f00b19fdvboxsyncexport SCRIPT_UTIL_CMD
a7aa94e0115a73841f34ebbfa00f63fa1904e51fvboxsyncCHECK_VERSION=yes
a7aa94e0115a73841f34ebbfa00f63fa1904e51fvboxsyncexport CHECK_VERSION
a7aa94e0115a73841f34ebbfa00f63fa1904e51fvboxsync. "${INSTALL_ROOT}/lib/_script-util.sh"
e91f2a55ed5a30342ec79ce273f3f4bad8283336vboxsyncRETURN_CODE=$?
32bf313cd8c0de52ef27b486f15945c55c94b038vboxsyncif test ${RETURN_CODE} -ne 0
210db75d2af02f67370c4a1be6570484d29eb394vboxsyncthen
e66c95fa9950a4d9c567db63a4a495bf086cc4bfvboxsync exit ${RETURN_CODE}
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsyncfi
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync# Specify the locations of important files that may be used when the server
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync# is starting.
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsyncCONFIG_FILE=${INSTANCE_ROOT}/config/config.ldif
e91f2a55ed5a30342ec79ce273f3f4bad8283336vboxsyncPID_FILE=${INSTANCE_ROOT}/logs/server.pid
bec9452711598b56e648192360cab88a6c3535e8vboxsyncLOG_FILE=${INSTANCE_ROOT}/logs/server.out
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsyncSTARTING_FILE=${INSTANCE_ROOT}/logs/server.starting
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync
111813bde8cc78d626b8d6fb3f6db67bd1b76da3vboxsync# See if the provided set of arguments were sufficient for us to be able to
683eff3070b1b86fe71b71af7fda82766ea19d17vboxsync# start the server or perform the requested operation. An exit code of 99
683eff3070b1b86fe71b71af7fda82766ea19d17vboxsync# means that it should be possible to start the server. An exit code of 98
d1c36fd86d36726777e3d6f9d040573e0aaf30devboxsync# means that the server is already running and we shouldn't try to start it.
d1c36fd86d36726777e3d6f9d040573e0aaf30devboxsync# An exit code of anything else means that we're not trying to start the server
ab455939477d81b7bb500586f88029d3a3c0b34cvboxsync# and we can just exit with that exit code.
111813bde8cc78d626b8d6fb3f6db67bd1b76da3vboxsync${OPENDS_JAVA_BIN} ${SCRIPT_NAME_ARG} org.opends.server.core.DirectoryServer \
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync --configClass org.opends.server.extensions.ConfigFileHandler \
d94da006d266643454eaeeb7e54c7c4a06bff515vboxsync --configFile "${CONFIG_FILE}" --checkStartability "${@}"
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsyncEC=${?}
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsyncif test ${EC} -eq 99 -o ${EC} -eq 103
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsyncthen
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync #
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync # run detach
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync #
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync touch "${STARTING_FILE}"
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync nohup "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} \
d67d8d3162b0d9cac99842fc7da74e8371453046vboxsync org.opends.server.core.DirectoryServer \
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsync --configClass org.opends.server.extensions.ConfigFileHandler \
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync --configFile "${CONFIG_FILE}" "${@}" > "${LOG_FILE}" 2>&1 &
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync echo $! > "${PID_FILE}"
2f655f58f4f10aed9b9b07d1379093ef469ba682vboxsync if test ${EC} -eq 99
2f655f58f4f10aed9b9b07d1379093ef469ba682vboxsync then
2f655f58f4f10aed9b9b07d1379093ef469ba682vboxsync "${OPENDS_JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsync --targetFile "${STARTING_FILE}" --logFile "${LOG_FILE}" "${@}"
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsync else
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsync "${OPENDS_JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsync --targetFile "${STARTING_FILE}" "${@}"
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync fi
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsync EC=${?}
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsync if test ${EC} -eq 0
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync then
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsync # An exit code of 98 means that the server is already running.
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsync ${OPENDS_JAVA_BIN} ${SCRIPT_NAME_ARG} org.opends.server.core.DirectoryServer \
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsync --configClass org.opends.server.extensions.ConfigFileHandler \
b39c3fa81cadaec00ebb2e7170a8db96998b7032vboxsync --configFile "${CONFIG_FILE}" --checkStartability > /dev/null 2>&1
b39c3fa81cadaec00ebb2e7170a8db96998b7032vboxsync EC=${?}
b39c3fa81cadaec00ebb2e7170a8db96998b7032vboxsync if test ${EC} -eq 98
b39c3fa81cadaec00ebb2e7170a8db96998b7032vboxsync then
b39c3fa81cadaec00ebb2e7170a8db96998b7032vboxsync exit 0
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsync else
2f655f58f4f10aed9b9b07d1379093ef469ba682vboxsync # Could not start the server
2f655f58f4f10aed9b9b07d1379093ef469ba682vboxsync exit 1
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync fi
317afd8ab14633faf6af4cfc0074b7476ba636c2vboxsync fi
f1630a6818621238c9c2338394b44995e318e108vboxsync exit ${EC}
f1630a6818621238c9c2338394b44995e318e108vboxsyncelse
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsync if test ${EC} -eq 100
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsync then
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsync #
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync # run no detach
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsync #
37136b5ecb07042e5ba50f86849a79d1cba5d5f1vboxsync echo $$ > "${PID_FILE}"
c14daac2bac51584dd4b94bf9ab51ed5b6f654aavboxsync rm -f "${LOG_FILE}"
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync exec "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} \
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync org.opends.server.core.DirectoryServer \
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync --configClass org.opends.server.extensions.ConfigFileHandler \
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync --configFile "${CONFIG_FILE}" "${@}"
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync elif test ${EC} -eq 104
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync 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