#!/sbin/sh
###############
# Product: PHKL_25609
# Fileset: PHKL_25609
# postinstall
# @(#) postinstall  $Revision: AUTO-GENERATED PATCH_11.00 (PHKL_25609)
#------------------------------------------------------------------#
# (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=PHKL_25609

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
#%# <static: PHKL_25026>
#%#
#%# <static: PHKL_24296>
#%#
########
# 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 the audio driver into machines
# that were originally built without audio.  If HP-UX is installed on
# a machine with audio, the AudioSubsystem will configure everything 
# correctly.  If there is no audio at the time of installation, it
# will not put audio in /stand/system and it will disable the Aserver
# from automatic startup (by setting AUDIO_SERVER=0 in 
# /etc/rc.config.d/audio ).  This puts audio in the system file
# and enables the Aserver to start at boot-up
#########################################################################

ioscan -kf | grep -e Audio -e audio > /tmp/audio_ioscan$$.out
if [[ -s /tmp/audio_ioscan$$.out ]];
then

    AddDriverEntry audio
    AddDriverEntry beep

    if [[ -r /etc/rc.config.d/audio ]];
    then
        grep "AUDIO_SERVER=0" /etc/rc.config.d/audio > /tmp/aserver$$.out
        if [[ -s /tmp/aserver$$.out ]];
	then

	     print "NOTE:    Enabling Aserver in /etc/rc.config.d/audio. To prevent the Aserver"
	     print "         from starting on boot-up, reset AUDIO_SERVER to 0"
		
	     # Enable Aserver to start
	     grep -v "AUDIO_SERVER=" /etc/rc.config.d/audio > /tmp/audio$$.tmp
	     echo "AUDIO_SERVER=1"  >> /tmp/audio$$.tmp
	     mv /tmp/audio$$.tmp /etc/rc.config.d/audio
	fi # if [[ -s /tmp/aserver$$.out ]]
	rm /tmp/aserver$$.out

    fi # if [[ -r /etc/rc.config.d/audio ]]

else # if [[ ! -s /tmp/audio_ioscan$$.out ]]
    my_model=`model`
    my_model=${my_model#*/} 
    my_model=${my_model%%??/*} 
    if [[ $my_model = '7' ]]
    then
 
        print "NOTE:    Unable to add audio to the system file. In order to put the"
        print "         audio driver into the kernel, edit /stand/system and add "
        print "         the line \"audio\", or add the audio driver using SAM.  To "
	print "         enable the audio server, edit /etc/rc.config.d/audio and verify"
	print "         that the line AUDIO_SERVER= is set to 1."	
   fi # if 700 machine
fi # if [[ -s /tmp/audio_ioscan$$.out ]]

rm /tmp/audio_ioscan$$.out

#%#
#%# </static: PHKL_24296>

#%#
#%# </static: PHKL_25026>




#%# DO NOT REMOVE ANYTHING AFTER THIS LINE
#%# <PATCH CONTROL SCRIPT LOG>
#%# PHKL_25026
#%# </PATCH CONTROL SCRIPT LOG>
 
##### END_OF_CUSTOMIZATION
exit $exitval
