#
#ident	"@(#)pkg.s52k:INSTALL	10.5"
#
FREL=3.2
LREL=4.0
CONDPATH=/install/cond
INSPATH=/install/new
PKGNAME=`cat ${INSPATH}/usr/options/s52k.name`

echo "\nInstalling the ${PKGNAME}"
echo "Copyright (c) 1987 AT&T"
echo "All Rights Reserved\n"

# check for valid release

SREL=`uname -r`

if [ "$SREL" -lt "$FREL" -o "$SREL" -ge "$LREL" ]
then
	echo "\nERROR: The $PKGNAME cannot be installed "
	echo "on UNIX System V Release $SREL.\n"
	exit
fi

cat <<EOF
Warning : If the AT&T 3B2 Cartridge Tape Utilities, AT&T 3B2
	  SCSI Cartridge Tape Utilities, or the AT&T 3B2 SCSI
	  9-Track Tape Utilities are to coexist with the
	  2KB File System Utilities, install the tape utilities
	  before installing the 2KB File System Utilities.
          If the 3B2 tape utilities are installed at a later date,
	  uninstall this package, install the appropriate tape 
	  package and then re-install the 2KB File System Utilities.

EOF
sleep 5
#
#	Determine how much space is needed by usr and root.
#

USRneeds=`expr "\`du -s ${INSPATH}/usr\`" : "\([0-9]*\).*"`
ROOTneeds=`expr "\`du -s ${INSPATH}/\`" : "\([0-9]*\).*"`
CONDneeds=`expr "\`du -s ${CONDPATH}/\`" : "\([0-9]*\).*"`
ROOTneeds=`expr ${ROOTneeds} - ${USRneeds}`
ROOTneeds=`expr ${ROOTneeds} + ${CONDneeds}`
#
#	Determine how much space is available.
#

USRspace=`expr "\`df /usr 2>/dev/null\`" : '.*: *\([0-9]*\)'`
ROOTspace=`expr "\`df / 2>/dev/null\`" : '.*: *\([0-9]*\)'`

#
#	Determine if the pagkage fits.
#

if
	[ ${USRspace} -lt ${USRneeds} ]
then
	echo "ERROR**  ${PKGNAME} cannot be installed --"
	echo "Not enough space on the hard disk."
	echo "There are ${USRspace} blocks available on the"
	echo "/usr file system --"
	echo "${USRneeds} blocks are needed."
	exit
elif
	[ ${ROOTspace} -lt ${ROOTneeds} ]
then
	echo "ERROR**  ${PKGNAME} cannot be installed --"
	echo "Not enough space on the hard disk."
	echo "There are ${ROOTspace} blocks available on the"
	echo "/ (root) file system --"
	echo "${ROOTneeds} blocks are needed."
	exit
fi

# check size of mainstore

MINMEM=2
MEMSZ=0
MEMSZ=`/etc/prtconf 2>/dev/null|/bin/grep "Memory size"|/bin/sed -e "s/[^0-9]//g"`;retrn=`echo $?`
if [ $retrn != 0 ]
then
cat <<EOF
WARNING: Failed to determine system memory size, assuming a 2
         megabyte memory configuration. If your system is equipped
         with more than 2 megabytes of memory, then the buffer pool
         configuration for the 2KB file system may need to be changed.
         This can be done by changing the tunable parameter "NF2KBUF"
         in the s52k configuration file (/etc/master.d/s52k). The 
         mkboot(1m) command MUST be executed on the S52K boot module 
         and the system rebooted (i.e. shutdown -i6) for the change 
         to take effect.

EOF
MEMSZ=2
sleep 5
fi
case $MEMSZ in
	[4-9]|[1-9][0-9]*)
		echo "\n200 2KB cache buffers will be configured for this package\n"
		BUF=200
		;;
	3)
		echo "\n150 2KB cache buffers will be configured for this package\n"
		BUF=150
		;;
	2)
		echo "\n100 2KB cache buffers will be configured for this package\n"
		BUF=100
		;;
	*)
		echo "ERROR** ${PKGNAME} cannot be installed --"
		echo "The system MUST be equipped with at least 2 "
		echo "megabytes of mainstore. The system is equipped"
		echo "with only ${MEMSZ} megabyte(s)."
		exit
		;;
esac
export BUF

#
#	Install the package.
#

cd ${INSPATH}
echo "\nThe following files are being installed: "
find . -print | cpio -pduvm /

#
#	Invoke Setup Script
#	setup script uses the BUF variable.

/install/install/setup

#
# Closing message installation complete
#

echo "\nInstallation of the ${PKGNAME} is complete.\n"
echo 'Execute "shutdown -i6 -g0 -y" and'
echo 'wait for the "Console Login:" prompt.'
exit
