setup revision 1777
d6fa26d0adaec6c910115be34fe7a5a5f402c14fMark Andrews#!/bin/sh
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater#
f0aad5341752aefe5059832f6cf3abc3283c6e16Tinderbox User# CDDL HEADER START
bef75d63d74f58abc0f834ed271526672777ba29Automatic Updater#
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User# The contents of this file are subject to the terms of the
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User# Common Development and Distribution License, Version 1.0 only
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User# (the "License"). You may not use this file except in compliance
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater# with the License.
d6fa26d0adaec6c910115be34fe7a5a5f402c14fMark Andrews#
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater# You can obtain a copy of the license at
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater# trunk/opends/resource/legal-notices/OpenDS.LICENSE
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User# See the License for the specific language governing permissions
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt# and limitations under the License.
cd32f419a8a5432fbb139f56ee73cbf68b9350ccTinderbox User#
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt# When distributing Covered Code, include this CDDL HEADER in each
1e9517ea2156b990be21f44676d3370318eacf17Tinderbox User# file and include the License file at
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater# add the following below this CDDL HEADER, with the fields enclosed
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater# by brackets "[]" replaced with your own identifying information:
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater# Portions Copyright [yyyy] [name of copyright owner]
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater#
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater# CDDL HEADER END
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater#
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt#
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater# Portions Copyright 2006-2007 Sun Microsystems, Inc.
1e9517ea2156b990be21f44676d3370318eacf17Tinderbox User
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater# See if JAVA_HOME is set. If not, then see if there is a java executable in
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater# the path and try to figure it out.
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updaterif test -z "${JAVA_BIN}"
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updaterthen
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User if test -z "${JAVA_HOME}"
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater then
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User if test -f "${INSTANCE_ROOT}/lib/set-java-home"
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User then
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User . "${INSTANCE_ROOT}/bin/set-java-home"
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User JAVA_BIN="${JAVA_HOME}/bin/java"
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User export JAVA_BIN
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User else
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater JAVA_BIN=`which java 2> /dev/null`
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User if test ${?} -eq 0
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User then
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User export JAVA_BIN
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User else
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater echo "Please set JAVA_HOME to the root of a Java 5 (or later) installation."
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User exit 1
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User fi
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User fi
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User else
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater JAVA_BIN="${JAVA_HOME}/bin/java"
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User export JAVA_BIN
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User fi
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox Userfi
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User# Explicitly set the PATH, LD_LIBRARY_PATH, LD_PRELOAD, and other important
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User# system environment variables for security and compatibility reasons.
7e71f05d8643aca84914437c900cb716444507e4Tinderbox UserPATH=/bin:/usr/bin
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox UserLD_LIBRARY_PATH=
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox UserLD_LIBRARY_PATH_32=
14a656f94b1fd0ababd84a772228dfa52276ba15Evan HuntLD_LIBRARY_PATH_64=
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic UpdaterLD_PRELOAD=
9d557856c2a19ec95ee73245f60a92f8675cf5baTinderbox UserLD_PRELOAD_32=
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic UpdaterLD_PRELOAD_64=
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox Userexport PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 \
9d557856c2a19ec95ee73245f60a92f8675cf5baTinderbox User LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_34
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater# Capture the current working directory so that we can change to it later.
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater# Then capture the location of this script and the Directory Server instance
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater# root so that we can use them to create appropriate paths.
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic UpdaterWORKING_DIR=`pwd`
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updatercd `dirname "${0}"`
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic UpdaterSCRIPT_DIR=`pwd`
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
14a656f94b1fd0ababd84a772228dfa52276ba15Evan HuntINSTANCE_ROOT=${SCRIPT_DIR}
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updaterexport INSTANCE_ROOT
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updatercd "${WORKING_DIR}"
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User# Configure the appropriate CLASSPATH.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox UserCLASSPATH=${INSTANCE_ROOT}/classes
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox Userfor JAR in ${INSTANCE_ROOT}/lib/*.jar
7e71f05d8643aca84914437c900cb716444507e4Tinderbox Userdo
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User CLASSPATH=${CLASSPATH}:${JAR}
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox Userdone
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox Userexport CLASSPATH
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User# Determine whether the detected Java environment is acceptable for use.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox Userif test -z "${JAVA_ARGS}"
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox Userthen
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater "${JAVA_BIN}" -client org.opends.server.tools.InstallDS -t 2> /dev/null
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater if test ${?} -eq 0
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User then
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User JAVA_ARGS="-client"
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater else
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater "${JAVA_BIN}" org.opends.server.tools.InstallDS -t 2> /dev/null
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater if test ${?} -ne 0
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater then
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater echo "ERROR: The detected Java version could not be used. Please set "
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater echo " JAVA_HOME to the root of a Java 5 (or later) installation."
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt exit 1
cd32f419a8a5432fbb139f56ee73cbf68b9350ccTinderbox User fi
1e9517ea2156b990be21f44676d3370318eacf17Tinderbox User fi
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updaterelse
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater "${JAVA_BIN}" ${JAVA_ARGS} org.opends.server.tools.InstallDS -t 2> /dev/null
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater if test ${?} -ne 0
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater then
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt echo "ERROR: The detected Java version could not be used. Please set "
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater echo " JAVA_HOME to the root of a Java 5 (or later) installation."
1e9517ea2156b990be21f44676d3370318eacf17Tinderbox User exit 1
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater fi
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updaterfi
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater
1ca759b3f5c0672b2a66bc02288fe010cabbfe37Tinderbox User# Launch the setup process.
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater"${JAVA_BIN}" org.opends.quicksetup.installer.InstallLauncher -P setup "${@}"
fc2381b901eb162810f54a11cc512b95f55a60dfAutomatic Updater
# return part
RETURN_CODE=$?
if test ${RETURN_CODE} -eq 50
then
# Version info was on requested
exit 0
else
exit ${RETURN_CODE}
fi