#!/sbin/sh
#############################
# Product: DesktopConfig
# Fileset: LITECONFIG
# postinstall
# @(#) $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


################################################################################
#
# Only modify the system file on the root file system. 
# If this is an NFSdiskless installation, or alternate 
# root, then configure will handle it.                
#
################################################################################

################################################################################
#
# 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 "/")
#
# Note: The lite_config "-r" option to modify the /etc/rc.config.d/<subsystem> 
#	configuration files is not used in the postinstall since this would
#	require the modification of a private directory.
#	This is only done in the configure script.
#
################################################################################

if [[ "${SW_ROOT_DIRECTORY}" = "/" && -z "${SW_DEFERRED_KERNBLD}" ]]; then
	#
	# Check to see if the Lite HP-UX Configuration has already been 
	# installed to the system.  If so, then issue a notification message.
	# Note that we only check for the kernel portion being installed
	# since the postinstall script only deals with this.
	# See lite_config for details.
	#
	LOGD="/var/adm/liteconfig"
	if [[ -f ${LOGD}/RemovedDrivers && \
	      -f ${LOGD}/ReducedTunable ]]; 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

	#
	# 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 [[ -z ${SW_DEFERRED_KERNBLD}" ]]


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