_mixed-script.sh revision 3824
445N/A#!/bin/sh
445N/A#
445N/A# CDDL HEADER START
445N/A#
445N/A# The contents of this file are subject to the terms of the
445N/A# Common Development and Distribution License, Version 1.0 only
445N/A# (the "License"). You may not use this file except in compliance
445N/A# with the License.
445N/A#
445N/A# You can obtain a copy of the license at
445N/A# trunk/opends/resource/legal-notices/OpenDS.LICENSE
445N/A# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
445N/A# See the License for the specific language governing permissions
445N/A# and limitations under the License.
445N/A#
445N/A# When distributing Covered Code, include this CDDL HEADER in each
445N/A# file and include the License file at
445N/A# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
445N/A# add the following below this CDDL HEADER, with the fields enclosed
445N/A# by brackets "[]" replaced with your own identifying information:
445N/A# Portions Copyright [yyyy] [name of copyright owner]
445N/A#
445N/A# CDDL HEADER END
445N/A#
445N/A#
445N/A# Copyright 2008 Sun Microsystems, Inc.
445N/A
445N/A
445N/A# This script is used to invoke processes that might be run on server or
445N/A# in client mode (depending on the state of the server and the arguments
445N/A# passed). It should not be invoked directly by end users.
445N/Aif test -z "${OPENDS_INVOKE_CLASS}"
445N/Athen
445N/A echo "ERROR: OPENDS_INVOKE_CLASS environment variable is not set."
445N/A exit 1
445N/Afi
445N/A
445N/A
445N/A# Capture the current working directory so that we can change to it later.
445N/A# Then capture the location of this script and the Directory Server install
445N/A# and instance root so that we can use them to create appropriate paths.
445N/AWORKING_DIR=`pwd`
445N/A
445N/Acd "`dirname "${0}"`"
445N/ASCRIPT_DIR=`pwd`
445N/A
445N/Acd ..
445N/AINSTALL_ROOT=`pwd`
445N/Aexport INSTALL_ROOT
445N/A
445N/Aif cat ${INSTALL_ROOT}/instance.loc | grep '^/' > /dev/null
445N/Athen
445N/A INSTANCE_ROOT=`cat ${INSTALL_ROOT}/instance.loc`
445N/A export INSTANCE_ROOT
445N/Aelse
445N/A INSTANCE_ROOT=${INSTALL_ROOT}/`cat ${INSTALL_ROOT}/instance.loc`
445N/A export INSTANCE_ROOT
445N/Afi
445N/A
445N/A
445N/Acd "${WORKING_DIR}"
445N/A
445N/AOLD_SCRIPT_NAME=${SCRIPT_NAME}
445N/ASCRIPT_NAME=${OLD_SCRIPT_NAME}.online
445N/Aexport SCRIPT_NAME
445N/A
445N/A# We keep this values to reset the environment before calling _script-util.sh
445N/A# for the second time.
445N/AORIGINAL_JAVA_ARGS=${OPENDS_JAVA_ARGS}
445N/AORIGINAL_JAVA_HOME=${OPENDS_JAVA_HOME}
445N/AORIGINAL_JAVA_BIN=${OPENDS_JAVA_BIN}
445N/A
445N/A# Set environment variables
445N/ASCRIPT_UTIL_CMD=set-full-environment
445N/Aexport SCRIPT_UTIL_CMD
445N/A. "${INSTALL_ROOT}/lib/_script-util.sh"
445N/ARETURN_CODE=$?
445N/Aif test ${RETURN_CODE} -ne 0
445N/Athen
445N/A exit ${RETURN_CODE}
445N/Afi
445N/A
445N/AMUST_CALL_AGAIN="false"
445N/A
445N/ASCRIPT_NAME_ARG=-Dorg.opends.server.scriptName=${OLD_SCRIPT_NAME}
445N/Aexport SCRIPT_NAME_ARG
445N/A
445N/A# Check whether is local or remote
445N/A"${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} "${OPENDS_INVOKE_CLASS}" \
445N/A --configClass org.opends.server.extensions.ConfigFileHandler \
445N/A --configFile "${INSTANCE_ROOT}/config/config.ldif" --testIfOffline "${@}"
445N/AEC=${?}
445N/Aif test ${EC} -eq 51
445N/Athen
445N/A # Set the original values that the user had on the environment in order to be
445N/A # sure that the script works with the proper arguments (in particular
445N/A # if the user specified not to overwrite the environment).
445N/A OPENDS_JAVA_ARGS=${ORIGINAL_JAVA_ARGS}
445N/A OPENDS_JAVA_HOME=${ORIGINAL_JAVA_HOME}
445N/A OPENDS_JAVA_BIN=${ORIGINAL_JAVA_BIN}
445N/A
445N/A # Set the environment to use the offline properties
445N/A SCRIPT_NAME=${OLD_SCRIPT_NAME}.offline
445N/A export SCRIPT_NAME
445N/A . "${INSTALL_ROOT}/lib/_script-util.sh"
445N/A RETURN_CODE=$?
445N/A if test ${RETURN_CODE} -ne 0
445N/A then
445N/A exit ${RETURN_CODE}
445N/A fi
445N/A MUST_CALL_AGAIN="true"
445N/Aelse
445N/A if test ${EC} -eq 52
445N/A then
445N/A MUST_CALL_AGAIN="true"
445N/A else
445N/A # This is likely a problem with the provided arguments.
445N/A exit ${EC}
445N/A fi
445N/Afi
445N/A
445N/Aif test ${MUST_CALL_AGAIN} = "true"
445N/Athen
445N/A SCRIPT_NAME_ARG=-Dorg.opends.server.scriptName=${OLD_SCRIPT_NAME}
445N/A export SCRIPT_NAME_ARG
445N/A
445N/A # Launch the server utility.
445N/A "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} ${SCRIPT_NAME_ARG} "${OPENDS_INVOKE_CLASS}" \
445N/A --configClass org.opends.server.extensions.ConfigFileHandler \
445N/A --configFile "${INSTANCE_ROOT}/config/config.ldif" "${@}"
445N/Afi
445N/A