6331N/A#!/bin/ksh93
6331N/A#
6331N/A# $Id$
2976N/A#
2976N/A# CDDL HEADER START
2976N/A#
2976N/A# The contents of this file are subject to the terms of the
2976N/A# Common Development and Distribution License, Version 1.0 only
2976N/A# (the "License"). You may not use this file except in compliance
2976N/A# with the License.
2976N/A#
2976N/A# You can obtain a copy of the license at
2976N/A# trunk/opends/resource/legal-notices/OpenDS.LICENSE
2976N/A# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
2976N/A# See the License for the specific language governing permissions
2976N/A# and limitations under the License.
2976N/A#
2976N/A# When distributing Covered Code, include this CDDL HEADER in each
2976N/A# file and include the License file at
2976N/A# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
2976N/A# add the following below this CDDL HEADER, with the fields enclosed
2976N/A# by brackets "[]" replaced with your own identifying information:
2976N/A# Portions Copyright [yyyy] [name of copyright owner]
2976N/A#
2976N/A# CDDL HEADER END
2976N/A#
2976N/A#
5236N/A# Copyright 2008-2010 Sun Microsystems, Inc.
6331N/A# Portions Copyright 2011 ForgeRock AS
6331N/A# Portions Copyright 2013 Jens Elkner
2976N/A
2976N/A# This script is used to invoke processes that might be run on server or
2976N/A# in client mode (depending on the state of the server and the arguments
2976N/A# passed). It should not be invoked directly by end users.
6331N/A
6331N/A# Capture the location of this script and the Directory Server install
6331N/A# and instance root so that we can use them to create appropriate paths.
6331N/A
6331N/A[[ ${FNTRACE} == 'ALL' || ${FNTRACE} == 'main' ]] && set -x
6331N/AINSTALL_ROOT="${.sh.file%/*/*}"
6331N/A
6331N/Aif [[ -z ${OPENDJ_INVOKE_CLASS} || -z ${SCRIPT_NAME} ]]; then
6331N/A SCRIPT_NAME=${.sh.file##*/}
6331N/A OIC=''
6331N/A case "$SCRIPT_NAME" in
6331N/A backup) #link
6331N/A # perform a backup of a Directory Server backend
6331N/A OIC='org.opends.server.tools.BackUpDB'
6331N/A ;;
6331N/A export-ldif) #link
6331N/A # perform an LDIF export for a Directory Server
6331N/A OIC='org.opends.server.tools.ExportLDIF'
6331N/A ;;
6331N/A import-ldif) #link
6331N/A # import LDIF data into a Directory Server backend
6331N/A OIC='org.opends.server.tools.ImportLDIF'
6331N/A ;;
6331N/A restore) #link
6331N/A # perform a restore of a Directory Server backend
6331N/A OIC='org.opends.server.tools.RestoreDB'
6331N/A ;;
6331N/A esac
6331N/A OPENDJ_INVOKE_CLASS=${OIC}
2976N/Afi
2976N/A
6331N/Aif [[ -z ${OPENDJ_INVOKE_CLASS} ]]; then
6331N/A print -u2 'ERROR: OPENDJ_INVOKE_CLASS environment variable is not set.'
6331N/A exit 1
6331N/Afi
2976N/A
3262N/A# We keep this values to reset the environment before calling _script-util.sh
3262N/A# for the second time.
6331N/AOLD_SCRIPT_NAME=${SCRIPT_NAME}
6331N/A
5636N/AORIGINAL_JAVA_ARGS=${OPENDJ_JAVA_ARGS}
5636N/AORIGINAL_JAVA_HOME=${OPENDJ_JAVA_HOME}
5636N/AORIGINAL_JAVA_BIN=${OPENDJ_JAVA_BIN}
3262N/A
2976N/A# Set environment variables
6331N/A. "${INSTALL_ROOT}"/lib/_script-util.sh
6331N/AcheckEnv 'set-full-environment'
2976N/A
6331N/AMUST_CALL_AGAIN=0
6331N/ASCRIPT_NAME=${OLD_SCRIPT_NAME}.online
6331N/ASCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=${OLD_SCRIPT_NAME}"
2976N/A
2976N/A# Check whether is local or remote
6331N/A"${OPENDJ_JAVA_BIN}" ${OPENDJ_JAVA_ARGS} ${SCRIPT_ARGS} ${SCRIPT_NAME_ARG} \
6331N/A -Dorg.opends.server.InstallRoot="${INSTALL_ROOT}" \
6331N/A -Dorg.opends.server.InstanceRoot="${INSTANCE_ROOT}" \
6331N/A ${OPENDJ_INVOKE_CLASS} \
6331N/A --configClass org.opends.server.extensions.ConfigFileHandler \
6331N/A --configFile "${INSTANCE_ROOT}"/config/config.ldif --testIfOffline "$@"
6331N/ARC=$?
6331N/Aif (( ${RC} == 51 )); then
6331N/A # Set the original values that the user had on the environment in order to
6331N/A # be sure that the script works with the proper arguments (in particular
6331N/A # if the user specified not to overwrite the environment).
6331N/A OPENDJ_JAVA_ARGS=${ORIGINAL_JAVA_ARGS}
6331N/A OPENDJ_JAVA_HOME=${ORIGINAL_JAVA_HOME}
6331N/A OPENDJ_JAVA_BIN=${ORIGINAL_JAVA_BIN}
3262N/A
6331N/A # Set the environment to use the offline properties
6331N/A SCRIPT_NAME=${OLD_SCRIPT_NAME}.offline
6331N/A checkEnv -i 'set-full-environment' "$@"
6331N/A MUST_CALL_AGAIN=1
6331N/Aelif (( ${RC} == 52 )); then
6331N/A MUST_CALL_AGAIN=1
2976N/Aelse
6331N/A # This is likely a problem with the provided arguments.
6331N/A exit ${RC}
2976N/Afi
2976N/A
6331N/Aif (( ${MUST_CALL_AGAIN} )); then
6331N/A # Launch the server utility.
6331N/A "${OPENDJ_JAVA_BIN}" ${OPENDJ_JAVA_ARGS} ${SCRIPT_ARGS} ${SCRIPT_NAME_ARG} \
6331N/A -Dorg.opends.server.InstallRoot="${INSTALL_ROOT}" \
6331N/A -Dorg.opends.server.InstanceRoot="${INSTANCE_ROOT}" \
6331N/A ${OPENDJ_INVOKE_CLASS} \
6331N/A --configClass org.opends.server.extensions.ConfigFileHandler \
6331N/A --configFile "${INSTANCE_ROOT}"/config/config.ldif "$@"
2976N/Afi