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