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