_server-script.sh revision f71f7a61dec7c9089378d14493ad564a1dedf0b5
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson#!/bin/sh
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson#
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# CDDL HEADER START
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson#
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# The contents of this file are subject to the terms of the
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# Common Development and Distribution License, Version 1.0 only
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# (the "License"). You may not use this file except in compliance
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# with the License.
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson#
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# You can obtain a copy of the license at
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# trunk/opends/resource/legal-notices/OpenDS.LICENSE
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# See the License for the specific language governing permissions
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# and limitations under the License.
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson#
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# When distributing Covered Code, include this CDDL HEADER in each
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# file and include the License file at
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# add the following below this CDDL HEADER, with the fields enclosed
f71f7a61dec7c9089378d14493ad564a1dedf0b5neil_a_wilson# by brackets "[]" replaced with your own identifying information:
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# Portions Copyright [yyyy] [name of copyright owner]
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson#
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# CDDL HEADER END
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson#
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson#
f71f7a61dec7c9089378d14493ad564a1dedf0b5neil_a_wilson# Portions Copyright 2006-2007 Sun Microsystems, Inc.
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# This script is used to invoke various server-side processes. It should not
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# be invoked directly by end users.
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilsonif test -z "${OPENDS_INVOKE_CLASS}"
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilsonthen
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson echo "ERROR: OPENDS_INVOKE_CLASS environment variable is not set."
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson exit 1
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilsonfi
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson
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
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilsoncd `dirname "${0}"`
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilsonSCRIPT_DIR=`pwd`
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilsoncd ..
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilsonINSTANCE_ROOT=`pwd`
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilsonexport INSTANCE_ROOT
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilsoncd "${WORKING_DIR}"
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# See if JAVA_HOME is set. If not, then see if there is a java executable in
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# the path and try to figure it out.
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilsonif test -z "${JAVA_BIN}"
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilsonthen
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson if test -z "${JAVA_HOME}"
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson then
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson if test -f "${INSTANCE_ROOT}/bin/set-java-home"
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson then
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson . "${INSTANCE_ROOT}/bin/set-java-home"
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson JAVA_BIN="${JAVA_HOME}/bin/java"
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson export JAVA_BIN
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson else
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson JAVA_BIN=`which java 2> /dev/null`
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson if test ${?} -eq 0
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson then
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson export JAVA_BIN
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson else
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson exit 1
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson fi
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson fi
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson else
69de0fe5b7ed905860bef5f86937d30cc206ef7dneil_a_wilson JAVA_BIN="${JAVA_HOME}/bin/java"
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson export JAVA_BIN
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson fi
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilsonfi
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# Explicitly set the PATH, LD_LIBRARY_PATH, LD_PRELOAD, and other important
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# system environment variables for security and compatibility reasons.
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilsonPATH=/bin:/usr/bin
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilsonLD_LIBRARY_PATH=
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilsonLD_LIBRARY_PATH_32=
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilsonLD_LIBRARY_PATH_64=
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilsonLD_PRELOAD=
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilsonLD_PRELOAD_32=
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilsonLD_PRELOAD_64=
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilsonexport PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 \
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_34
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# Configure the appropriate CLASSPATH.
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilsonCLASSPATH=${INSTANCE_ROOT}/classes
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilsonfor JAR in ${INSTANCE_ROOT}/lib/*.jar
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilsondo
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson CLASSPATH=${CLASSPATH}:${JAR}
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilsondone
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilsonexport CLASSPATH
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson# Launch the appropriate server utility.
266c5071a91fda6a5159b08ea8d45261228d03d5neil_a_wilson"${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} "${OPENDS_INVOKE_CLASS}" \
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson --configClass org.opends.server.extensions.ConfigFileHandler \
0cf0e19d7abb0e7659df6d191269f96b3ffe7f45neil_a_wilson --configFile "${INSTANCE_ROOT}/config/config.ldif" "${@}"