#!/sbin/sh
#------------------------------------------------------------------#
#
# HPUX_ID: @(#) $Revision: 19.5 $ generated on Thu Dec  6 17:43:22 EST 2001
# Product: OS-Core
# Fileset: CORE2-KRN
# Postinstall script for func0 driver patch
#
# (c)Copyright 1983-2001 Hewlett-Packard Co.,  All Rights Reserved.
#
#------------------------------------------------------------------#
# SD postinstall script template for 11.X patches.                 #
#------------------------------------------------------------------#
# This file is optional for all 11.X patches.  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=PHNE_25603

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

########
# 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()
{
     driver=$1
     mod_systemfile $SW_SYSTEM_FILE_PATH -a $driver
     if [[ $? -ne 0 ]]
       then
          print  "ERROR:   Cannot update $SW_SYSTEM_FILE_PATH to"
          print  "         include the $driver driver."
          exitval=$FAILURE
     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 -kf | grep -q -i -e unknown -e unclaimed );
then
   if (! grep -q -e func0 /stand/system ); then
      AddDriverEntry func0
   fi
fi   # if ioscan

exit $exitval
