#! /sbin/sh
########
# Product: OS-Core
# Fileset: CORE-KRN
# checkinstall
# @(#) $Revision: 1.2.98.3 $
########
#
# (c) Copyright Hewlett-Packard Company, 1994
#
#######$

# The global variables SUCCESS, FAILURE, WARNING, EXCLUDE, PATH, ROOT,
# SW_CTL_SCRIPT_NAME, _pf, PRODUCT, and FILESET are all set by control_utils.

UTILS=/usr/lbin/sw/control_utils
if [[ ! -f $UTILS ]]
then
    print "ERROR:   Cannot find the sh functions library $UTILS."
    exit 1
fi

. $UTILS

exitval=$SUCCESS		# Preset to everything is alright.

#########################
#			#
# Function defintions	#
#			#
#########################

# RequireLVM()
#
# Returns 0 if LVM is mandatory, 1 otherwise
#
RequireLVM()
{

    typeset alt tgt				# string variables for swlist options
    typeset -i Req=0 NotReq=1			# mnemonics for exit statuses

    if [[ "$SW_ROOT_DIRECTORY" = "/" ]]; then	# Not doing alternative root install
	alt=""
	tgt=""
    else					# alternate root install
	alt="-r"
	tgt="@ $SW_ROOT_DIRECTORY"
    fi

    if swlist -l fileset $alt HPUX9.SDS $tgt 2>/dev/null | grep -q HPUX9.SDS
    then					# 9.x update with multi-disk SDS in use
	return $Req
    elif [[ -s "$SW_ROOT_DIRECTORY/etc/lvmtab" ]]
    then					# lvmtab exists and contains data
	return $Req
    else
	return $NoReq
    fi
}

#################
#		#
# Main Program	#
#		#
#################

typeset -i OldSys=$(uname -r | grep 'B.10.0[0-9]' | wc -l)	# 1 if post MR, 0 otherwise

if [[ $OldSys -eq 0 || -n "$SW_INITIAL_INSTALL" ]]; then	# Only do if major update or cold install
    if RequireLVM; then
	if is_software_selected LVM.LVM-KRN; then
	    :
	else
	    print "ERROR:   The filesets LVM.LVM-KRN and LVM.LVM-RUN must be selected in order"
	    print "         to ensure that all disks will be accessible after the new kernel is"
	    print "         put into place. This is because there is either an \"/etc/lvmtab\" file"
	    print "         which contains lvm configuration information on the system, or the"
	    print "         command \"/etc/sdsadmin\" indicates that there is a multiple disk"
	    print "         software disk striping (SDS) array on the system (or cluster).  In"
	    print "         either case, data will be lost without LVM."
	    exitval=$FAILURE
	fi # is_software_selected LVM.LVM-KRN
    fi # RequireLVM
fi # [[ $OldSys -eq 0 || -n "$SW_INITIAL_INSTALL" ]]


exit $exitval 
