#!/sbin/sh
#############################
# Product: DesktopConfig
# Fileset: LITECONFIG
# configure
# @(#) $Revision: 1.3.98.1 $
#############################
#
# (c) Copyright Hewlett-Packard Company, 1993
#
################################################################################
#                            
# Setup general environment. 
#                           
################################################################################

UTILS="/usr/lbin/sw/control_utils"
if [[ ! -f $UTILS ]]
then
	print "ERROR:   Cannot find $UTILS"
	exit 1
fi
. $UTILS
exitval=$SUCCESS			# Anticipate success

#
# Check to see if the Lite HP-UX Configuration has already been 
# installed to the system.  If so, then issue a notification message.
# Note: the "SavedRcConf" log file below is only created as a result of 
# the configure script invoking lite_config with the "-r" option.
# See lite_config for details.
#
LOGD="/var/adm/liteconfig"
if [[ -f ${LOGD}/RemovedDrivers && \
      -f ${LOGD}/ReducedTunable && \
      -f ${LOGD}/SavedRcConf ]]; then
	print "NOTE:    The \"Lite HP-UX Configuration\" has already been"
	print "         installed to the system as a result of a previous"
	print "         swinstall of \"$PRODUCT\".  Proceeding with an"
	print "         incremental update of \"$PRODUCT\"; any previous"
	print "         changes made by the user to the current version"
	print "         of the \"Lite HP-UX Configuration\" will not be"
	print "         overwritten.  If you wish to completely re-install"
	print "         \"$PRODUCT\", you must first remove \"$PRODUCT\""
	print "         (using swremove) before installing it again."
fi

#
# Verify the existence of the lite_config utility.
#
LITE_CONFIG="${SW_CONTROL_DIRECTORY}/lite_config"
if [[ ! -x ${LITE_CONFIG} ]]; then
	print "ERROR:   Internal error: cannot execute $LITE_CONFIG."
	print "         This is a fatal swinstall error and should be"
	print "         reported to the appropriate HP customer support"
	print "         representative."
	exit $FAILURE
fi


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

################################################################################
#
# Perform system file "lite" modifications.
#
# Call the lite_config utility to perform the "lite" work:
# 	o Remove optional drivers from the system file
# 	o Reduce the values of several kernel tunable parameters
# Refer to the lite_config utility for details.
#
# Lite_config run-string: 
#	lite_config -l|-u [-c] -r|-s<systemfile> [-R<systemroot>]
#
#	Options:
#	-l	"Lite"    mode of operation (minimize kernel/system size)
#	-u	"Un-lite" mode of operation (revert back to original size)
#	-c	Cold-install environment 
#	-r	Process /etc/rc.config.d subsystems
#	-s	Process the system file specified by <systemfile>
#	-R	Specify the system root (default is "/")
#
################################################################################

if [[ -n "${SW_DEFERRED_KERNBLD}" ]]; then
	#
	# Invoke lite_config.
	# If this is a first-time (cold) installation, 
	# invoke lite_config with the "-c" option.  
	# (No need to use the "-R" option because lite_config directly
	# reads the ${SW_ROOT_DIRECTORY} environment variable.)
	#
	OPTIONS=""
	[[ -n "${SW_INITIAL_INSTALL}" ]] && OPTIONS="-c"
	${LITE_CONFIG} -l ${OPTIONS} -s ${SW_SYSTEM_FILE_PATH} 2>/dev/null
	status=$?
	[[ $status -ne 0 && $exitval -ne $FAILURE ]] && exitval=$status
    
fi	# end of if [[ -n "${SW_DEFERRED_KERNBLD}" ]]


################################################################################
#			      
# Perform /etc/rc.config.d/<subsystem> "lite" modifications.
#
# Invoke lite_config in order to turn-off several optional subsystems.
# Subsystems are disabled by setting their corresponding control 
# variables in the /etc/rc.config.d/<subsystem> files to "0".
# Refer to the lite_config utility for details.
#			      
################################################################################

${LITE_CONFIG} -l -r 2>/dev/null
status=$?
[[ $status -ne 0 && $exitval -ne $FAILURE ]] && exitval=$status


################################################################################
#
# Finished (return $exitval status).
#
################################################################################
exit $exitval
