#! /sbin/sh
########
# Product: Ignite-UX
# checkinstall
# @(#) $Revision 2.0 $
########
#
# (c) Copyright Hewlett-Packard Company 1997
#
########################################################################

##########################################################################
# This is the product level checkinstall script for Ignite-UX.
#
# -  prevents loading on a diskless client. 
# -  prevents loading if NetInstall.HPUX-Install exists, and
#    $OK_TO_RM_FILE does not exist.
#

OK_TO_RM_FILE=/tmp/okay_to_remove_net_install

UTILS=/usr/lbin/sw/control_utils
if [ -f $UTILS ]
then
    . $UTILS
else
    echo "ERROR:   Cannot find $UTILS"
    exit 1
fi

if [[ $SW_ROOT_DIRECTORY != "/" ]]
then
    echo "ERROR:   Ignite-UX cannot  be installed in an alternate"
    echo "         root environment (i.e. A diskless client)"
    exit $EXCLUDE
fi

# to prevent parsing problems from verbose debug output
# unset any SDU_DEBUG flags

set -A debug_vars $(set|awk '$0 ~ /^SDU_DEBUG/ {FS="=";print $1}')
[[ -n ${debug_vars[*]} ]] && unset ${debug_vars[*]}
unset debug_vars 

if [ -f /usr/lib/sw/hpux.install/700INSTALL -o -f /usr/lbin/instl_bootd ]
then
     swlist HPUX-Install >/tmp/$$.swlist  2>&1
     if $(grep -q "not found" /tmp/$$.swlist) ; then
         :
         # This is the case of a system having some HPUX-Install patches
         # loaded without having the HPUX-Install product itself loaded.
         # The paches will be removed by the preinstall script, no need
         # to mention this case - just causes confusion.
     else
        if [ -f $OK_TO_RM_FILE ] ; then
            echo "\
NOTE:    The NetInstall.HPUX-Install product will be removed since
         the file $OK_TO_RM_FILE exists."
        else
             echo "\
ERROR:   The NetInstall.HPUX-Install product appears to be installed
         on the system.  The Ignite-UX product is a replacement for
         the NetInstall capability and thus cannot both be loaded at
         the same time.  You may either use swremove to remove
         NetInstall, or touch the file $OK_TO_RM_FILE
         and retry using swinstall to load Ignite-UX again."
             rm -f /tmp/$$.swlist
             exit $FAILURE
         fi
     fi
     rm -f /tmp/$$.swlist
fi

exit $SUCCESS
