#!/sbin/sh
###############
# Product: OS-Core
# Fileset: CORE2-KRN
# postinstall (Base SuperIO)
################
#
# (c) Copyright Hewlett-Packard Company, 1998,1999
#############################################################
# The purpose of this 
# script is to prepare for a kernel build when required by the     
# install conditions.  The script can also drive events that must 
# occur before a system reboot occurs.                           
#------------------------------------------------------------------

_PATCHID=PHKL_20152

UTILS="/usr/lbin/sw/control_utils"

if [ ! -f $UTILS ]; then
    echo "ERROR:   Cannot find $UTILS"
    exit 1
fi

. $UTILS
exitval=$SUCCESS

#####
##### Insert any code you may require at this point in the script.
##### Pay attention to the exitval variable and set appropriately
##### in your code.  If you are unsure as to what types of operations
##### are legal in this file and what types aren't, consult the 
##### "Guidelines for SD Control Scripts" document.
#####
##### START_CUSTOMIZATION_HERE

SED=sed
MV="mv -f"
RM="rm -f"

sio_master=$SW_ROOT_DIRECTORY/usr/conf/master.d/superio
sio_prodfs="OS-Core.CORE2-KRN"
device="superio"
driver="superio"

########
# FUNCTIONS
########
# AddDriverEntry
#
#   Purpose:  To add to the system file a driver that this fileset has 
#	delivered. Set the $exitval value based on the return value from 
#	mod_systemfile().  If multiple additions, ensure that a FAILURE 
#	value of $exitval is not reduced by a later SUCCESS return.
#
AddDriverEntry()
{
   mod_systemfile $SW_SYSTEM_FILE_PATH -a $1
   if [[ $? -ne 0 ]]
     then
       print  "ERROR:   Cannot update required $1 functionality ($FILESET)."
       exitval=$FAILURE
   else
       driver_added="yes"
   fi
} #END AddDriverEntry

#########################################################################
#########################################################################
# This script part is intended to insert post 11.00 drivers that are 
# needed by the kernel when new driver patches are installed and certain 
# hardware is present.
#
# This addition must be done at the patch level since it is fixing a 
# difficulty caused by the early truncate_sys call from the control
# scripts in the CORE-KRN fileset, but depends on matching the new 
# drivers defined in master.d/core-hpux which is delivered in KERN2-RUN.
#########################################################################

if [[ -x /sbin/ioscan ]] && ( /sbin/ioscan -f | grep -q $device)
then
    AddDriverEntry $driver
fi   #if ioscan

exit $exitval
