#! /sbin/sh
########
# Product: LVM
# Fileset: LVM-KRN
# checkremove
# @(#) $Revision: 1.2.98.2 $
#########
#
# (c) Copyright Hewlett-Packard Company, 1993
#
#########

# 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

###########################################################################

if [[ $SW_SESSION_IS_KERNEL = "TRUE" ]]; then
    # Check if any volume groups exist on the system

    ${SW_ROOT_DIRECTORY}sbin/vgdisplay 2> /dev/null > /tmp/lvm.$$

    if [ -s /tmp/lvm.$$ ] ; then
	echo "ERROR:   LVM volume groups exist on the system.  In order to"
	echo "         remove the $FILESET fileset, you must remove the "
	echo "         volume groups and re-execute the swremove command."
	exit $FAILURE
    fi
    exit $SUCCESS
else
    print "WARNING: Removal of the $FILESET fileset will make it impossible"
    print "         to build a new kernel.  This precludes changing certain"
    print "         system parameters and installing products that modify or"
    print "         add to the kernel."
    exit $WARNING
fi
