upgrade revision 37f9a536593b696e5a3dcec443e1475f22fb5afd
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# 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
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara# See if the environment variables are set. If not, then see if there is a java
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara# executable in the path and try to figure it out.
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergaraif test -z "${OPENDS_JAVA_BIN}"
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergarathen
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara if test -z "${OPENDS_JAVA_HOME}"
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara then
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara if test -f "${INSTANCE_ROOT}/lib/set-java-home"
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara then
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara . "${INSTANCE_ROOT}/lib/set-java-home"
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara OPENDS_JAVA_BIN="${OPENDS_JAVA_HOME}/bin/java"
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara export OPENDS_JAVA_BIN
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara else
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara if test -z "${JAVA_BIN}"
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara then
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara if test -z "${JAVA_HOME}"
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara then
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara OPENDS_JAVA_BIN=`which java 2> /dev/null`
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara if test ${?} -eq 0
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara then
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara export OPENDS_JAVA_BIN
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara else
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara echo "Please set OPENDS_JAVA_HOME to the root of a Java 5 (or later) installation."
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara exit 1
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara fi
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara else
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara OPENDS_JAVA_BIN="${JAVA_HOME}/bin/java"
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara export OPENDS_JAVA_BIN
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara fi
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara else
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara OPENDS_JAVA_BIN="${JAVA_BIN}"
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara export OPENDS_JAVA_BIN
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara fi
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara fi
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara else
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara OPENDS_JAVA_BIN="${OPENDS_JAVA_HOME}/bin/java"
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara export OPENDS_JAVA_BIN
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara fi
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergarafi
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter# Configure the appropriate CLASSPATH to test.
857225469c51bedb8c0566aa7757800cfaac4075kenneth_suterfor JAR in ${INSTANCE_ROOT}/tmp/upgrade/lib/*.jar
857225469c51bedb8c0566aa7757800cfaac4075kenneth_suterdo
857225469c51bedb8c0566aa7757800cfaac4075kenneth_suter CLASSPATH=${CLASSPATH}:${JAR}
857225469c51bedb8c0566aa7757800cfaac4075kenneth_suterdone
857225469c51bedb8c0566aa7757800cfaac4075kenneth_suterCLASSPATH=${CLASSPATH}:${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
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara "${OPENDS_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
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara "${OPENDS_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 "
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara echo " OPENDS_JAVA_HOME to the root of a Java 5 (or later) installation."
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter exit 1
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter fi
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter fi
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterelse
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara "${OPENDS_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 "
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara echo " OPENDS_JAVA_HOME to the root of a Java 5.0 installation."
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter exit 1
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter fi
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suterfi
5b3741e0620fd2baaa974cecc2c2d953bb7d4fbbkenneth_suter
d18ac24c35f0fd0cd2414730ebce9edcfea8b47ekenneth_suterif [ -r "${INSTANCE_ROOT}/tmp/upgrade" ]
857225469c51bedb8c0566aa7757800cfaac4075kenneth_suterthen
d18ac24c35f0fd0cd2414730ebce9edcfea8b47ekenneth_suter rm -fr "${INSTANCE_ROOT}/tmp/upgrade"
857225469c51bedb8c0566aa7757800cfaac4075kenneth_suterfi
df438df5438041e3e57cb6301f6b64d34f9c89eckenneth_suter
358aa64445313154ce8f5e0acca0966f5a40fa0bkenneth_suter# Launch the build extractor.
358aa64445313154ce8f5e0acca0966f5a40fa0bkenneth_suter# Configure the appropriate CLASSPATH.
358aa64445313154ce8f5e0acca0966f5a40fa0bkenneth_suter# BuildExtractor uses the existing install's
358aa64445313154ce8f5e0acca0966f5a40fa0bkenneth_suter# jars
358aa64445313154ce8f5e0acca0966f5a40fa0bkenneth_suterCLASSPATH=${INSTANCE_ROOT}/classes
358aa64445313154ce8f5e0acca0966f5a40fa0bkenneth_suterfor JAR in ${INSTANCE_ROOT}/lib/*.jar
358aa64445313154ce8f5e0acca0966f5a40fa0bkenneth_suterdo
358aa64445313154ce8f5e0acca0966f5a40fa0bkenneth_suter CLASSPATH=${CLASSPATH}:${JAR}
358aa64445313154ce8f5e0acca0966f5a40fa0bkenneth_suterdone
358aa64445313154ce8f5e0acca0966f5a40fa0bkenneth_suterexport CLASSPATH
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter# Run the build extractor first. An exit code of 99 from the extractor
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter# means that this is indeed an upgrade (as opposed to a reversion) and
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter# that the upgrade should continue. An exit code of 98 means that this
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter# operation is a reversion. An exit code of 50 means that the usage
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter# statement was printed and there is nothing else to do
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara"${OPENDS_JAVA_BIN}" org.opends.quicksetup.upgrader.BuildExtractor "${@}"
da7ab15aee42edf1c4ff33f66ca717f019b4a578lutoffRETURN_CODE=$?
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suterif test ${RETURN_CODE} -eq 99
358aa64445313154ce8f5e0acca0966f5a40fa0bkenneth_suterthen
a68203de3c573de383ff57dc62a62ef102344985kenneth_suter # Configure the appropriate CLASSPATH.
358aa64445313154ce8f5e0acca0966f5a40fa0bkenneth_suter # Unlike BuildExtractor, the Upgrader uses
358aa64445313154ce8f5e0acca0966f5a40fa0bkenneth_suter # the newly extracted build's jars.
358aa64445313154ce8f5e0acca0966f5a40fa0bkenneth_suter CLASSPATH=${INSTANCE_ROOT}/tmp/upgrade/classes
358aa64445313154ce8f5e0acca0966f5a40fa0bkenneth_suter for JAR in ${INSTANCE_ROOT}/tmp/upgrade/lib/*.jar
a68203de3c573de383ff57dc62a62ef102344985kenneth_suter do
358aa64445313154ce8f5e0acca0966f5a40fa0bkenneth_suter CLASSPATH=${JAR}:${CLASSPATH}
a68203de3c573de383ff57dc62a62ef102344985kenneth_suter done
358aa64445313154ce8f5e0acca0966f5a40fa0bkenneth_suter # Launch the upgrade process.
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara "${OPENDS_JAVA_BIN}" org.opends.quicksetup.upgrader.UpgradeLauncher "${@}"
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suterelif test ${RETURN_CODE} -eq 98
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suterthen
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter # Copy jars to a temporary place from which to run the reverter
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter # in order to avoid potential file lock issues.
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter mkdir -p tmp/revert
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter cp -R lib tmp/revert
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter if test ${?} -ne 0
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter then
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter echo "ERROR: Failed to initialize reversion."
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter exit 101
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter else
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter CLASSPATH=${INSTANCE_ROOT}/tmp/revert/classes
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter for JAR in ${INSTANCE_ROOT}/tmp/revert/lib/*.jar
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter do
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter CLASSPATH=${JAR}:${CLASSPATH}
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter done
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter # Launch the upgrade process.
37f9a536593b696e5a3dcec443e1475f22fb5afdjvergara "${OPENDS_JAVA_BIN}" org.opends.quicksetup.upgrader.ReversionLauncher "${@}"
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter fi
da7ab15aee42edf1c4ff33f66ca717f019b4a578lutoffelif test ${RETURN_CODE} -eq 50
da7ab15aee42edf1c4ff33f66ca717f019b4a578lutoffthen
da7ab15aee42edf1c4ff33f66ca717f019b4a578lutoff # Version info was on requested
da7ab15aee42edf1c4ff33f66ca717f019b4a578lutoff exit 0
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suterelif test ${RETURN_CODE} -eq 0
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suterthen
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter # Usage printed
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter exit 0
358aa64445313154ce8f5e0acca0966f5a40fa0bkenneth_suterelse
bae806fb480fd70aa10de1cfdc7850ae6f95cb81kenneth_suter # Some unknown return code returned
f5bbd7023cc96dccff382d0f7911d356fcd9769dkenneth_suter exit 101
857225469c51bedb8c0566aa7757800cfaac4075kenneth_suterfi