start-ds revision 7070667c2dffad87009999bdeb16d5305e0afdbe
97a9a944b5887e91042b019776c41d5dd74557aferikabele#!/bin/sh
97a9a944b5887e91042b019776c41d5dd74557aferikabele#
97a9a944b5887e91042b019776c41d5dd74557aferikabele# CDDL HEADER START
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive#
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive# The contents of this file are subject to the terms of the
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive# Common Development and Distribution License, Version 1.0 only
b686b6a420bde7f78c416b90be11db94cb789979nd# (the "License"). You may not use this file except in compliance
b686b6a420bde7f78c416b90be11db94cb789979nd# with the License.
b686b6a420bde7f78c416b90be11db94cb789979nd#
b686b6a420bde7f78c416b90be11db94cb789979nd# You can obtain a copy of the license at
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen# trunk/opends/resource/legal-notices/OpenDS.LICENSE
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen# See the License for the specific language governing permissions
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen# and limitations under the License.
b686b6a420bde7f78c416b90be11db94cb789979nd#
b686b6a420bde7f78c416b90be11db94cb789979nd# When distributing Covered Code, include this CDDL HEADER in each
b686b6a420bde7f78c416b90be11db94cb789979nd# file and include the License file at
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
3f08db06526d6901aa08c110b5bc7dde6bc39905nd# add the following below this CDDL HEADER, with the fields enclosed
b686b6a420bde7f78c416b90be11db94cb789979nd# by brackets "[]" replaced with your own identifying information:
b686b6a420bde7f78c416b90be11db94cb789979nd# Portions Copyright [yyyy] [name of copyright owner]
b686b6a420bde7f78c416b90be11db94cb789979nd#
3f08db06526d6901aa08c110b5bc7dde6bc39905nd# CDDL HEADER END
b686b6a420bde7f78c416b90be11db94cb789979nd#
b686b6a420bde7f78c416b90be11db94cb789979nd#
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd# Portions Copyright 2006-2007 Sun Microsystems, Inc.
4aa805f8500255bc52a4c03259fe46df10a1d07cyoshiki
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor
7f5b59ccc63c0c0e3e678a168f09ee6a2f51f9d0nd# Capture the current working directory so that we can change to it later.
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung# Then capture the location of this script and the Directory Server instance
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd# root so that we can use them to create appropriate paths.
b686b6a420bde7f78c416b90be11db94cb789979ndWORKING_DIR=`pwd`
b686b6a420bde7f78c416b90be11db94cb789979nd
b686b6a420bde7f78c416b90be11db94cb789979ndcd `dirname "${0}"`
b686b6a420bde7f78c416b90be11db94cb789979ndSCRIPT_DIR=`pwd`
9e8d9311a964a8ba9ef5694a369b61b2d4c8c041slive
b686b6a420bde7f78c416b90be11db94cb789979ndcd ..
b686b6a420bde7f78c416b90be11db94cb789979ndINSTANCE_ROOT=`pwd`
06ba4a61654b3763ad65f52283832ebf058fdf1csliveexport INSTANCE_ROOT
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslivecd "${WORKING_DIR}"
b686b6a420bde7f78c416b90be11db94cb789979nd
b686b6a420bde7f78c416b90be11db94cb789979nd
b686b6a420bde7f78c416b90be11db94cb789979nd# See if JAVA_HOME is set. If not, then see if there is a java executable in
b686b6a420bde7f78c416b90be11db94cb789979nd# the path and try to figure it out.
117c1f888a14e73cdd821dc6c23eb0411144a41cndif test -z "${JAVA_BIN}"
b686b6a420bde7f78c416b90be11db94cb789979ndthen
b686b6a420bde7f78c416b90be11db94cb789979nd if test -z "${JAVA_HOME}"
b686b6a420bde7f78c416b90be11db94cb789979nd then
b686b6a420bde7f78c416b90be11db94cb789979nd if test -f "${INSTANCE_ROOT}/bin/set-java-home"
69d3d5f6232f961fd77392db8a975a346fd9cff6nd then
b686b6a420bde7f78c416b90be11db94cb789979nd . "${INSTANCE_ROOT}/bin/set-java-home"
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh JAVA_BIN="${JAVA_HOME}/bin/java"
b686b6a420bde7f78c416b90be11db94cb789979nd export JAVA_BIN
b686b6a420bde7f78c416b90be11db94cb789979nd else
b686b6a420bde7f78c416b90be11db94cb789979nd JAVA_BIN=`which java 2> /dev/null`
06ba4a61654b3763ad65f52283832ebf058fdf1cslive if test ${?} -eq 0
c3a3c963ad3f5b4d816b66117406d4e793049119slive then
c3a3c963ad3f5b4d816b66117406d4e793049119slive export JAVA_BIN
c3a3c963ad3f5b4d816b66117406d4e793049119slive else
06ba4a61654b3763ad65f52283832ebf058fdf1cslive echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
c3a3c963ad3f5b4d816b66117406d4e793049119slive exit 1
c3a3c963ad3f5b4d816b66117406d4e793049119slive fi
20e951959be9ae3d183d42bfce4d8a35b8efc154jim fi
06ba4a61654b3763ad65f52283832ebf058fdf1cslive else
17ade6df5ec233536985eb1c130a906c725dd614humbedooh JAVA_BIN="${JAVA_HOME}/bin/java"
17ade6df5ec233536985eb1c130a906c725dd614humbedooh export JAVA_BIN
17ade6df5ec233536985eb1c130a906c725dd614humbedooh fi
17ade6df5ec233536985eb1c130a906c725dd614humbedoohfi
17ade6df5ec233536985eb1c130a906c725dd614humbedooh
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
3b58542e01ec69422f3086db5825a12fc77b726end# Explicitly set the PATH, LD_LIBRARY_PATH, LD_PRELOAD, and other important
3b58542e01ec69422f3086db5825a12fc77b726end# system environment variables for security and compatibility reasons.
b686b6a420bde7f78c416b90be11db94cb789979ndPATH=/bin:/usr/bin
b686b6a420bde7f78c416b90be11db94cb789979ndLD_LIBRARY_PATH=
69d3d5f6232f961fd77392db8a975a346fd9cff6ndLD_LIBRARY_PATH_32=
69d3d5f6232f961fd77392db8a975a346fd9cff6ndLD_LIBRARY_PATH_64=
3e78df7c8027de6e02326dff46742413de0bfc03covenerLD_PRELOAD=
3e78df7c8027de6e02326dff46742413de0bfc03covenerLD_PRELOAD_32=
69d3d5f6232f961fd77392db8a975a346fd9cff6ndLD_PRELOAD_64=
69d3d5f6232f961fd77392db8a975a346fd9cff6ndexport PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 \
69d3d5f6232f961fd77392db8a975a346fd9cff6nd LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_34
69d3d5f6232f961fd77392db8a975a346fd9cff6nd
69d3d5f6232f961fd77392db8a975a346fd9cff6nd
69d3d5f6232f961fd77392db8a975a346fd9cff6nd# Configure the appropriate CLASSPATH.
69d3d5f6232f961fd77392db8a975a346fd9cff6ndCLASSPATH=${INSTANCE_ROOT}/classes
69d3d5f6232f961fd77392db8a975a346fd9cff6ndfor JAR in ${INSTANCE_ROOT}/lib/*.jar
69d3d5f6232f961fd77392db8a975a346fd9cff6nddo
69d3d5f6232f961fd77392db8a975a346fd9cff6nd CLASSPATH=${CLASSPATH}:${JAR}
69d3d5f6232f961fd77392db8a975a346fd9cff6nddone
69d3d5f6232f961fd77392db8a975a346fd9cff6ndexport CLASSPATH
69d3d5f6232f961fd77392db8a975a346fd9cff6nd
69d3d5f6232f961fd77392db8a975a346fd9cff6nd
69d3d5f6232f961fd77392db8a975a346fd9cff6nd# Specify the locations of important files that may be used when the server
69d3d5f6232f961fd77392db8a975a346fd9cff6nd# is starting.
69d3d5f6232f961fd77392db8a975a346fd9cff6ndCONFIG_FILE=${INSTANCE_ROOT}/config/config.ldif
b686b6a420bde7f78c416b90be11db94cb789979ndPID_FILE=${INSTANCE_ROOT}/logs/server.pid
06ba4a61654b3763ad65f52283832ebf058fdf1csliveLOG_FILE=${INSTANCE_ROOT}/logs/server.out
06ba4a61654b3763ad65f52283832ebf058fdf1csliveSTARTING_FILE=${INSTANCE_ROOT}/logs/server.starting
3b58542e01ec69422f3086db5825a12fc77b726end
3b58542e01ec69422f3086db5825a12fc77b726end
3b58542e01ec69422f3086db5825a12fc77b726end# Specify the script name so that it may be provided in command-line usage.
3b58542e01ec69422f3086db5825a12fc77b726endSCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=start-ds"
17ade6df5ec233536985eb1c130a906c725dd614humbedoohexport SCRIPT_NAME_ARG
3b58542e01ec69422f3086db5825a12fc77b726end
17ade6df5ec233536985eb1c130a906c725dd614humbedooh
17ade6df5ec233536985eb1c130a906c725dd614humbedooh# See if the provided set of arguments were sufficient for us to be able to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive# start the server or perform the requested operation. An exit code of 99
06ba4a61654b3763ad65f52283832ebf058fdf1cslive# means that it should be possible to start the server. An exit code of 98
3b58542e01ec69422f3086db5825a12fc77b726end# means that the server is already running and we shouldn't try to start it.
3b58542e01ec69422f3086db5825a12fc77b726end# An exit code of anything else means that we're not trying to start the server
3b58542e01ec69422f3086db5825a12fc77b726end# and we can just exit with that exit code.
3b58542e01ec69422f3086db5825a12fc77b726end${JAVA_BIN} ${SCRIPT_NAME_ARG} org.opends.server.core.DirectoryServer \
3b58542e01ec69422f3086db5825a12fc77b726end --configClass org.opends.server.extensions.ConfigFileHandler \
3b58542e01ec69422f3086db5825a12fc77b726end --configFile "${CONFIG_FILE}" --checkStartability "${@}"
3b58542e01ec69422f3086db5825a12fc77b726endEC=${?}
17ade6df5ec233536985eb1c130a906c725dd614humbedoohif test ${EC} -eq 99
8eb7c1fd1d6abcf2529dcb265573b194aba56794chrisdthen
17ade6df5ec233536985eb1c130a906c725dd614humbedooh #
17ade6df5ec233536985eb1c130a906c725dd614humbedooh # run detach
06ba4a61654b3763ad65f52283832ebf058fdf1cslive #
3b58542e01ec69422f3086db5825a12fc77b726end touch "${STARTING_FILE}"
3b58542e01ec69422f3086db5825a12fc77b726end nohup "${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
3b58542e01ec69422f3086db5825a12fc77b726end org.opends.server.core.DirectoryServer \
3b58542e01ec69422f3086db5825a12fc77b726end --configClass org.opends.server.extensions.ConfigFileHandler \
3b58542e01ec69422f3086db5825a12fc77b726end --configFile "${CONFIG_FILE}" "${@}" > "${LOG_FILE}" 2>&1 &
06ba4a61654b3763ad65f52283832ebf058fdf1cslive echo $! > "${PID_FILE}"
06ba4a61654b3763ad65f52283832ebf058fdf1cslive "${JAVA_BIN}" -Xms8M -Xmx8M org.opends.server.tools.WaitForFileDelete \
3b58542e01ec69422f3086db5825a12fc77b726end --targetFile "${STARTING_FILE}" --logFile "${LOG_FILE}"
3b58542e01ec69422f3086db5825a12fc77b726end exit ${?}
3b58542e01ec69422f3086db5825a12fc77b726endelse
17ade6df5ec233536985eb1c130a906c725dd614humbedooh if test ${EC} -eq 100
17ade6df5ec233536985eb1c130a906c725dd614humbedooh then
17ade6df5ec233536985eb1c130a906c725dd614humbedooh #
17ade6df5ec233536985eb1c130a906c725dd614humbedooh # run no detach
3b58542e01ec69422f3086db5825a12fc77b726end #
3b58542e01ec69422f3086db5825a12fc77b726end echo $$ > "${PID_FILE}"
3b58542e01ec69422f3086db5825a12fc77b726end rm -f "${PID_FILE}" "${LOG_FILE}"
3b58542e01ec69422f3086db5825a12fc77b726end exec "${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
3b58542e01ec69422f3086db5825a12fc77b726end org.opends.server.core.DirectoryServer \
3b58542e01ec69422f3086db5825a12fc77b726end --configClass org.opends.server.extensions.ConfigFileHandler \
3b58542e01ec69422f3086db5825a12fc77b726end --configFile "${CONFIG_FILE}" "${@}"
3b58542e01ec69422f3086db5825a12fc77b726end else
3b58542e01ec69422f3086db5825a12fc77b726end #
3b58542e01ec69422f3086db5825a12fc77b726end # an error or the server is already started. Just return the code provided
3b58542e01ec69422f3086db5825a12fc77b726end # by checkstartability
8eb7c1fd1d6abcf2529dcb265573b194aba56794chrisd #
8eb7c1fd1d6abcf2529dcb265573b194aba56794chrisd exit ${EC}
3b58542e01ec69422f3086db5825a12fc77b726end fi
3b58542e01ec69422f3086db5825a12fc77b726endfi
3b58542e01ec69422f3086db5825a12fc77b726end