#! /sbin/sh
########################################################
# Product: HP-UX
# Fileset: DISKLESS
# configure
# @(#) $Revision: 1.3.98.1 $
########################################################
#
# (c) Copyright Hewlett-Packard Company, 1993
#
########################################################

UTILS=/usr/lbin/sw/control_utils
if [[ ! -f $UTILS ]]
then
    print "ERROR:   Cannot find the sh functions library $UTILS."
    exit 1      # FAILURE mode is 1 (as defined later by set_env)
fi
. $UTILS

exitval=$SUCCESS                # Anticipate success

########################################################
#                                                      #
# 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   #
    #                                        #
    ##########################################
    
    # Subsystems for DISKLESS are:
    for driver in \
        dskless
    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 #
    #                                      #
    ########################################

    # Tunables for DISKLESS clients are:
    for tunable in \
        dskless_node=1 	  \
        remote_nfs_swap=1 \
        allocate_fs_swapmap=1
    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}" ]]

#
# Fin.
#

exit $exitval
