#!/bin/ksh93
#
# $Id$
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at
# trunk/opends/resource/legal-notices/OpenDS.LICENSE
# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at
# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
# add the following below this CDDL HEADER, with the fields enclosed
# by brackets "[]" replaced with your own identifying information:
# Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2006-2010 Sun Microsystems, Inc.
# Portions Copyright 2011 ForgeRock AS
# Portions Copyright 2013 Jens Elkner
# This script is used to invoke various client-side processes. It should not
# be invoked directly by end users.
[[ ${FNTRACE} == 'ALL' || ${FNTRACE} == 'main' ]] && set -x
INSTALL_ROOT="${.sh.file%/*/*}"
CHECK=''
if [[ -z ${OPENDJ_INVOKE_CLASS} || -z ${SCRIPT_NAME} ]]; then
SCRIPT_NAME=${.sh.file##*/}
OIC=''
case "$SCRIPT_NAME" in
base64) #link
OIC='org.opends.server.util.Base64'
;;
control-panel) #link
# display the control panel
OIC='org.opends.guitools.controlpanel.ControlPanelLauncher'
;;
create-rc-script) #link
OIC='org.opends.server.tools.CreateRCScript'
CHECK='-i'
;;
dsconfig) #link
# perform configuration ops on the server
OIC='org.opends.server.tools.dsconfig.DSConfig'
;;
dsframework) #link
# perform ops with the global admin framework
OIC='org.opends.server.admin.client.cli.DsFrameworkCliMain'
;;
dsjavaproperties) #link
# Basically reads $INSTANCE_ROOT/config/java.properties and creates
# $INSTANCE_ROOT/lib/set-java-home, which gets sourced by
# $INSTALL_ROOT/lib/_script-util.sh ...
OIC='org.opends.server.tools.JavaPropertiesTool'
CHECK='-i'
;;
ldapcompare) #link
# perform LDAP compare ops
OIC='org.opends.server.tools.LDAPCompare'
;;
ldapdelete) #link
# perform LDAP delete ops
OIC='org.opends.server.tools.LDAPDelete'
;;
ldapmodify) #link
# perform LDAP add, delete, modify, and modify DN ops
OIC='org.opends.server.tools.LDAPModify'
;;
ldappasswordmodify) #link
# perform LDAP password modify ops
OIC='org.opends.server.tools.LDAPPasswordModify'
;;
ldapsearch) #link
# perform LDAP search ops
OIC='org.opends.server.tools.LDAPSearch'
;;
manage-account) #link
OIC='org.opends.server.tools.ManageAccount'
;;
manage-tasks) #link
# manage tasks in the Directory Server
OIC='org.opends.server.tools.ManageTasks'
;;
status) #link
# display the status panel
OIC='org.opends.server.tools.status.StatusCli'
;;
esac
OPENDJ_INVOKE_CLASS=${OIC}
fi
if [[ -z ${OPENDJ_INVOKE_CLASS} ]]; then
print -u2 'ERROR: OPENDJ_INVOKE_CLASS environment variable is not set.'
exit 1
fi
# Set environment variables
. "${INSTALL_ROOT}"/lib/_script-util.sh
checkEnv ${CHECK} 'set-full-environment' "$@"
if [[ ${SCRIPT_NAME} == 'dsjavaproperties' ]] && ! isVersionOrHelp "$@" ; then
# special for src/quicksetup/org/opends/quicksetup/util/Utils.java
if [[ ${SCRIPT_UTIL_CMD} == 'set-full-environment-and-test-java' ]]; then
checkEnv 'test-java' # set-full-environment already done above
return 0
fi
# "OpenDJ Admin" (ODA) profile support: let the ODA specify as an additional
# argument, what file to use (because per default ODA has no permission to
# modify files in ${INSTANCE_ROOT}).
[[ $1 == '-Q' ]] && FILE="$2" || FILE="$1"
if [[ -f "${FILE}" ]]; then
cp "${FILE}" "${INSTANCE_ROOT}"/config/java.properties || exit 1
if [[ $1 == '-Q' ]]; then
shift 2
set -- '-Q' "$@"
else
shift
fi
fi
fi
# Launch the appropriate client utility.
"${OPENDJ_JAVA_BIN}" ${OPENDJ_JAVA_ARGS} ${SCRIPT_ARGS} ${SCRIPT_NAME_ARG} \
-Dorg.opends.server.InstallRoot="${INSTALL_ROOT}" \
-Dorg.opends.server.InstanceRoot="${INSTANCE_ROOT}" \
${OPENDJ_INVOKE_CLASS} "$@"