upgrade revision 5b3741e0620fd2baaa974cecc2c2d953bb7d4fbb
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter#!/bin/sh
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter#
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# CDDL HEADER START
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter#
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# The contents of this file are subject to the terms of the
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# Common Development and Distribution License, Version 1.0 only
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# (the "License"). You may not use this file except in compliance
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# with the License.
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter#
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# You can obtain a copy of the license at
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# trunk/opends/resource/legal-notices/OpenDS.LICENSE
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# See the License for the specific language governing permissions
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# and limitations under the License.
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter#
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# When distributing Covered Code, include this CDDL HEADER in each
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# file and include the License file at
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# add the following below this CDDL HEADER, with the fields enclosed
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# by brackets "[]" replaced with your own identifying information:
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# Portions Copyright [yyyy] [name of copyright owner]
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter#
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# CDDL HEADER END
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter#
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter#
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# Portions Copyright 2006-2007 Sun Microsystems, Inc.
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# See if JAVA_HOME is set. If not, then see if there is a java executable in
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# the path and try to figure it out.
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterif test -z "${JAVA_BIN}"
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterthen
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter if test -z "${JAVA_HOME}"
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter then
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter if test -f "${INSTANCE_ROOT}/bin/set-java-home"
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter then
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter . "${INSTANCE_ROOT}/bin/set-java-home"
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter JAVA_BIN="${JAVA_HOME}/bin/java"
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter export JAVA_BIN
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter else
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter JAVA_BIN=`which java 2> /dev/null`
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter if test ${?} -eq 0
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter then
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter export JAVA_BIN
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter else
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter exit 1
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter fi
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter fi
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter else
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter JAVA_BIN="${JAVA_HOME}/bin/java"
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter export JAVA_BIN
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter fi
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterfi
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# Explicitly set the PATH, LD_LIBRARY_PATH, LD_PRELOAD, and other important
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# system environment variables for security and compatibility reasons.
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterPATH=/bin:/usr/bin
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterLD_LIBRARY_PATH=
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterLD_LIBRARY_PATH_32=
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterLD_LIBRARY_PATH_64=
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterLD_PRELOAD=
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterLD_PRELOAD_32=
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterLD_PRELOAD_64=
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterexport PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 \
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_34
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# Capture the current working directory so that we can change to it later.
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# Then capture the location of this script and the Directory Server instance
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# root so that we can use them to create appropriate paths.
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterWORKING_DIR=`pwd`
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_sutercd `dirname "${0}"`
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterSCRIPT_DIR=`pwd`
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterINSTANCE_ROOT=${SCRIPT_DIR}
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterexport INSTANCE_ROOT
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_sutercd "${WORKING_DIR}"
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# Configure the appropriate CLASSPATH to test.
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterCLASSPATH=${INSTANCE_ROOT}/classes
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterfor JAR in ${INSTANCE_ROOT}/lib/*.jar
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterdo
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter CLASSPATH=${CLASSPATH}:${JAR}
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterdone
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterexport CLASSPATH
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# Determine whether the detected Java environment is acceptable for use.
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterif test -z "${JAVA_ARGS}"
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterthen
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter "${JAVA_BIN}" -client org.opends.server.tools.InstallDS -t 2> /dev/null
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter if test ${?} -eq 0
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter then
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter JAVA_ARGS="-client"
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter else
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter "${JAVA_BIN}" org.opends.server.tools.InstallDS -t 2> /dev/null
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter if test ${?} -ne 0
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter then
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter echo "ERROR: The detected Java version could not be used. Please set "
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter echo " JAVA_HOME to the root of a Java 5.0 installation."
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter exit 1
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter fi
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter fi
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterelse
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter "${JAVA_BIN}" ${JAVA_ARGS} org.opends.server.tools.InstallDS -t 2> /dev/null
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter if test ${?} -ne 0
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter then
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter echo "ERROR: The detected Java version could not be used. Please set "
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter echo " JAVA_HOME to the root of a Java 5.0 installation."
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter exit 1
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter fi
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterfi
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# Launch the uninstall process.
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter"${JAVA_BIN}" org.opends.quicksetup.upgrader.UpgradeLauncher "${@}"