#
#	@(#)pkg.sysadm:sysadm/INSTALL	1.6.1.2
#

INSPATH=/install/new
PKGNAME=`cat ${INSPATH}/usr/options/sysadm.name`

echo "Installing the ${PKGNAME}"
echo "Copyright (c) 1984 AT&T"
echo "All Rights Reserved"

#
#	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]*\).*"`
ROOTneeds=`expr ${ROOTneeds} - ${USRneeds} + 30`

#
#	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

#
#	Install the package.
#

cd ${INSPATH}
echo "The following files are being installed: "
find . -print | cpio -pduvm /
ln /etc/dcopy1K /etc/dcopy
ln /etc/fsdb1K /etc/fsdb
echo "Installation of the ${PKGNAME} complete. "
