#! /usr/bin/sh
#
# ident	"%Z%%M%	%I%	%E% SMI"
#
# Copyright (c) 2000 by Sun Microsystems, Inc.
# All rights reserved.
#
# This is the pre-install shell script for patch 110722-01.  The
# specific purpose of this pre-install script is to bar installation of
# the VxVM/VxDMP/AP interface related patch materials when a customer
# has an older version of Veritas installed that does not support the
# new VxVM/VxDMP/AP interface (e.g., pre-VxVM3.1.1).
#
# This is achieved by enforcing the installation requirements described
# in the AP installation notes.  Briefly, AP is installed before
# Veritas.  In cases where Veritas and AP exist prior to this new
# installation, the old version of Veritas is de-installed,
# subsequently the old version of AP is removed.  Next, AP is
# re-installed, followed by Veritas.
#
# Given the installation requirements, In most situations, these checks
# should be moot, as the normal installation process for AP instructs
# customers to install AP prior to any potentially dependent volume
# manager (e.g., Veritas).
#
# The advent of the new VxVM/VxDMP/AP interface increases the
# importance of a coherent installation, as described in the
# installation instructions, hence this new check.
#
# Finally, the existence of
#
# "SUNBugID 4405589: dex hangs after installed patch
#		     110722-01 using vxvm3.1 and ap2.3.1"
#
# presents an even greater need for customers to follow the required
# installation procedure.  Until this bug is fixed, customers must not
# install this patch when they intend to use pre-VxVM3.1.1 versions of
# Veritas.  Conversely, this patch is required for customers that will
# be using Veritas3.1.1.
#
# When SUNBugID 4405589 is fixed, this patch will be applicable to any
# version of Veritas, however, the installation requirements remain the
# same, and the script can continue to balk installations when Veritas
# is found on the system.
#
#
##############################################################
# CHANGE HISTORY (REVERSE CHRONOLOGICAL)
#
# 2001-Jan-24 motu	Initial creation.
#
##############################################################

# Set preliminary file and path name variables
if [ "${ROOTDIR}" = "/" ]; then
	VXVM_DIR="/opt/VRTSvxvm"
	EXTRA=""
else
	VXVM_DIR="${ROOTDIR}/opt/VRTSvxvm"
	EXTRA="-R ${ROOTDIR}"
fi

AWK="/usr/bin/awk"
FMT="/usr/bin/fmt"
PKGINFO="/usr/bin/pkginfo ${EXTRA}"
PKGPARAM="/usr/bin/pkgparam ${EXTRA}"

trap "exit 1" 1 2 3 15

#
# Veritas installation will be determined by the existence of the
# Veritas Volume Manager Package VRTSvxvm
#
VXVM="VRTSvxvm"
VERITAS_INSTALLED="`${PKGINFO} ${VXVM} 2>/dev/null`"
if [ -z "${VERITAS_INSTALLED}" ]; then
	VERITAS_INSTALLED="`${PKGINFO} SUNWvxvm 2>/dev/null`"
	if [ -n "${VERITAS_INSTALLED}" ]; then
		VXVM="SUNWvxvm"
	fi
fi

if [ -n "${VERITAS_INSTALLED}" ]; then
	VERITAS_VERSION="`${PKGPARAM} ${VXVM} VERSION 2>/dev/null | ${AWK} -F, '{print $1}'`"

	${FMT} << EOF

	Application of this patch requires adherence to the AP2.3.1
	installation process.  This process requires the removal of
	Veritas prior to AP/Veritas installation.  Please follow the AP
	installation instructions, paying particular attention to the
	volume manager deconfiguration/reconfiguration process.

	You are running Veritas Volume Manager ${VERITAS_VERSION} (${VXVM})

EOF
	if [ "${VERITAS_VERSION}" != "3.1.1" ]; then
		fmt << EOF
	This patch is not recomended with Veritas Volume Manager
	versions that predate version 3.1.1
EOF
	fi
else
	${FMT} << EOF

	If the customer intends to run versions of Veritas that
	are equal to VxVM3.1.1 or later, then application of this
	AP2.3.1 patch is required prior to Veritas installation.

	If the customer intends to run versions of Veritas that
	are earlier than VxVM3.1.1, then this patch should not
	be applied.

	If you intend to run a version of Veritas that pre-dates
	VxVM3.1.1, then remove this patch before installing your
	pre-VxVM3.1.1 version of Veritas.
EOF
fi
echo "\nPress the return key to continue or Control-C to quit."
read A
exit 0
