#! /sbin/sh
##############
# Product: Streams-TIO
# Fileset: STRTIO-KRN
# configure
# @(#) $Revision: 1.4.98.1 $
##############
#
# (c) Copyright Hewlett-Packard Company, 1993
#
#####################

#set -a                          # Export all variables

SUCCESS=0			# SDU expected return codes
WARNING=2
FAILURE=1

exitval=$SUCCESS                # Anticipate success

UTILS=/usr/lbin/sw/control_utils
if [[ ! -f $UTILS ]]
then
    print "ERROR:   Cannot find the sh functions library $UTILS."
    exit $FAILURE
fi
. $UTILS

#set_env		# sets ARCH, PATH, ROOT, PRODUCT, & FILESET

########################################################
#						       #
# If configuring a diskless client, or a disk that had #
# been mounted as an alternate root during swinstall,  #
# perform all necessary  kernel modifications.	       #
#						       #
########################################################

if [[ -n "${SW_DEFERRED_KERNBLD}" ]]
then
    
    ##########################################
    #                                        #
    # Place any drivers into /stand/system   #
    # (Using SW_SYSTEM_FILE_PATH set by SD). #
    #                                        #
    ##########################################
    
    for driver in \
	ldterm \
	ptem \
	pts \
	ptm \
	pckt
    do
        mod_systemfile $SW_SYSTEM_FILE_PATH -a "$driver"
        if [[ $? -ne 0 ]]
        then
            print "ERROR:   Cannot update $SW_SYSTEM_FILE_PATH to"
            print "         include $driver ($FILESET functionality)."
            exitval=$FAILURE 
        fi
    done
    
    ########################################
    #				           #
    # Modify any tunable kernel parameters #
    #				           #
    ########################################

    for tunable in \
	nstrpty=60
    do
        mod_systemfile $SW_SYSTEM_FILE_PATH -t ${tunable%%=*} "${tunable##*=}"
        if [[ $? -ne 0 ]]
        then
            print "WARNING: Cannot update $SW_SYSTEM_FILE_PATH to"
            print "         Alter tunable parameter ${tunable%%=*} to ${tunable##*=}"
            if [[ $exitval -ne $FAILURE ]] # never upgrade the exit status
            then
            	exitval=$WARNING
            fi
        fi
    done

fi	# end of if [[ -n "${SW_DEFERRED_KERNBLD}" ]]

################################
#			       #
# Create Device Special Files. #
#			       #
################################

echo "NOTE:	Installing special files for pseudo driver ptm."

insf -d ptm > /dev/null 2>&1

if [[ $? -ne 0 ]] ; then
	echo "ERROR:	Cannot create Streams PTY Master device file."
	exitval=$FAILURE
fi

echo "NOTE:	Installing special files for pseudo driver pts."
insf -d pts > /dev/null 2>&1

if [[ $? -ne 0 ]] ; then
	echo "ERROR:	Cannot create Streams PTY Slave device files."
	exitval=$FAILURE
fi


#############
# Finished. #
#############

exit $exitval
