upgrade revision 2976
1051N/A#!/bin/sh
1051N/A#
1051N/A# CDDL HEADER START
1051N/A#
1051N/A# The contents of this file are subject to the terms of the
1051N/A# Common Development and Distribution License, Version 1.0 only
1051N/A# (the "License"). You may not use this file except in compliance
1051N/A# with the License.
1051N/A#
1051N/A# You can obtain a copy of the license at
1051N/A# trunk/opends/resource/legal-notices/OpenDS.LICENSE
1051N/A# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
1051N/A# See the License for the specific language governing permissions
1051N/A# and limitations under the License.
1051N/A#
1051N/A# When distributing Covered Code, include this CDDL HEADER in each
1051N/A# file and include the License file at
1051N/A# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
1051N/A# add the following below this CDDL HEADER, with the fields enclosed
1051N/A# by brackets "[]" replaced with your own identifying information:
1051N/A# Portions Copyright [yyyy] [name of copyright owner]
1051N/A#
1051N/A# CDDL HEADER END
1051N/A#
1051N/A#
1051N/A# Portions Copyright 2006-2007 Sun Microsystems, Inc.
1051N/A
1051N/A# Capture the current working directory so that we can change to it later.
1051N/A# Then capture the location of this script and the Directory Server instance
1051N/A# root so that we can use them to create appropriate paths.
1051N/AWORKING_DIR=`pwd`
1051N/A
1051N/Acd `dirname "${0}"`
1051N/ASCRIPT_DIR=`pwd`
1051N/A
1051N/AINSTANCE_ROOT=${SCRIPT_DIR}
1051N/Aexport INSTANCE_ROOT
1051N/A
2976N/ASCRIPT_NAME=upgrade
2976N/Aexport SCRIPT_NAME
2976N/A
1051N/Acd "${WORKING_DIR}"
1051N/A
2976N/A# Set java home
2976N/ASCRIPT_UTIL_CMD=set-java-home-and-args
2976N/Aexport SCRIPT_UTIL_CMD
2976N/A. "${INSTANCE_ROOT}/lib/_script-util.sh"
2976N/ARETURN_CODE=$?
2976N/Aif test ${RETURN_CODE} -ne 0
2650N/Athen
2976N/A exit ${RETURN_CODE}
2650N/Afi
2650N/A
2976N/A# Set environment variables
2976N/ASCRIPT_UTIL_CMD=set-environment-vars
2976N/Aexport SCRIPT_UTIL_CMD
2976N/A. "${INSTANCE_ROOT}/lib/_script-util.sh"
2976N/ARETURN_CODE=$?
2976N/Aif test ${RETURN_CODE} -ne 0
2976N/Athen
2976N/A exit ${RETURN_CODE}
2976N/Afi
1051N/A
1051N/A# Configure the appropriate CLASSPATH to test.
1105N/Afor JAR in ${INSTANCE_ROOT}/tmp/upgrade/lib/*.jar
1105N/Ado
1105N/A CLASSPATH=${CLASSPATH}:${JAR}
1105N/Adone
1105N/ACLASSPATH=${CLASSPATH}:${INSTANCE_ROOT}/classes
1051N/Afor JAR in ${INSTANCE_ROOT}/lib/*.jar
1051N/Ado
1051N/A CLASSPATH=${CLASSPATH}:${JAR}
1051N/Adone
1051N/Aexport CLASSPATH
1051N/A
2976N/A# Test the java installation
2976N/ASCRIPT_UTIL_CMD=test-java
2976N/Aexport SCRIPT_UTIL_CMD
2976N/A. "${INSTANCE_ROOT}/lib/_script-util.sh"
2976N/ARETURN_CODE=$?
2976N/Aif test ${RETURN_CODE} -ne 0
1051N/Athen
2976N/A exit ${RETURN_CODE}
1051N/Afi
1051N/A
1247N/Aif [ -r "${INSTANCE_ROOT}/tmp/upgrade" ]
1105N/Athen
1247N/A rm -fr "${INSTANCE_ROOT}/tmp/upgrade"
1105N/Afi
1114N/A
1345N/A# Launch the build extractor.
1345N/A# Configure the appropriate CLASSPATH.
1345N/A# BuildExtractor uses the existing install's
1345N/A# jars
1345N/ACLASSPATH=${INSTANCE_ROOT}/classes
1345N/Afor JAR in ${INSTANCE_ROOT}/lib/*.jar
1345N/Ado
1345N/A CLASSPATH=${CLASSPATH}:${JAR}
1345N/Adone
1345N/Aexport CLASSPATH
2324N/A
2324N/A# Run the build extractor first. An exit code of 99 from the extractor
2324N/A# means that this is indeed an upgrade (as opposed to a reversion) and
2324N/A# that the upgrade should continue. An exit code of 98 means that this
2324N/A# operation is a reversion. An exit code of 50 means that the usage
2324N/A# statement was printed and there is nothing else to do
2324N/A
2976N/A"${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} org.opends.quicksetup.upgrader.BuildExtractor "${@}"
1777N/ARETURN_CODE=$?
2324N/Aif test ${RETURN_CODE} -eq 99
1345N/Athen
1265N/A # Configure the appropriate CLASSPATH.
1345N/A # Unlike BuildExtractor, the Upgrader uses
1345N/A # the newly extracted build's jars.
1345N/A CLASSPATH=${INSTANCE_ROOT}/tmp/upgrade/classes
1345N/A for JAR in ${INSTANCE_ROOT}/tmp/upgrade/lib/*.jar
1265N/A do
1345N/A CLASSPATH=${JAR}:${CLASSPATH}
1265N/A done
1345N/A # Launch the upgrade process.
2976N/A "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} org.opends.quicksetup.upgrader.UpgradeLauncher "${@}"
2324N/Aelif test ${RETURN_CODE} -eq 98
2324N/Athen
2324N/A # Copy jars to a temporary place from which to run the reverter
2324N/A # in order to avoid potential file lock issues.
2324N/A mkdir -p tmp/revert
2324N/A cp -R lib tmp/revert
2324N/A if test ${?} -ne 0
2324N/A then
2324N/A echo "ERROR: Failed to initialize reversion."
2324N/A exit 101
2324N/A else
2324N/A CLASSPATH=${INSTANCE_ROOT}/tmp/revert/classes
2324N/A for JAR in ${INSTANCE_ROOT}/tmp/revert/lib/*.jar
2324N/A do
2324N/A CLASSPATH=${JAR}:${CLASSPATH}
2324N/A done
2324N/A # Launch the upgrade process.
2976N/A "${OPENDS_JAVA_BIN}" ${OPENDS_JAVA_ARGS} org.opends.quicksetup.upgrader.ReversionLauncher "${@}"
2324N/A fi
1777N/Aelif test ${RETURN_CODE} -eq 50
1777N/Athen
1777N/A # Version info was on requested
1777N/A exit 0
2324N/Aelif test ${RETURN_CODE} -eq 0
2324N/Athen
2324N/A # Usage printed
2324N/A exit 0
1345N/Aelse
2324N/A # Some unknown return code returned
1516N/A exit 101
1105N/Afi