PATH=/bin:/usr/bin:/usr/ucb
export PATH
if test ! -d /usr/apx5
then
	echo "Making /usr/apx5 directory..."
	mkdir /usr/apx5
	chown root /usr/apx5
	chgrp root /usr/apx5
	chmod 755 /usr/apx5
fi
cd /apx5
echo "Begin APX5 installation at "`date`
find . -print | cpio -pdmau /usr/apx5
cd /usr/apx5/gen/src/ker860
cp kernel kernel486
/usr/apx5/bin/fixmagic kernel486
echo "All APX5 files have been copied into /usr/apx5."
echo ""
echo "A new system (/unix) will now be generated.  The old /unix will be"
echo "renamed to '/unix.preapx'.  This could take a few minutes..."
echo ""
cd /usr/apx5/gen/src/drv860
cp Master.dsp Master
cp System.dsp System
cp Node.dsp Node
cp Space.dsp Space.c
cp i860.o Driver.o
cp i860.h /usr/include/sys
cp /usr/apx5/etc/K90i860 /etc/rc0.d/K90i860
if test -s /usr/apx5/etc/fp.old
then	echo "/usr/apx5/etc/fp.old exists already; this is OK."
else
	cp /etc/conf/sdevice.d/fp /usr/apx5/etc/fp.old
fi
cat /usr/apx5/etc/fp > /etc/conf/sdevice.d/fp
if test -d /etc/conf/pack.d/i860
then
	echo "Installing over old APX driver..."
	/etc/conf/bin/idinstall -u i860
else
	/etc/conf/bin/idinstall -a i860
fi
cd /etc/conf/bin
rm -f /etc/conf/cf.d/unix
if ./idbuild
then
	echo "The build of the kernel (/unix) was successful..."
	echo "The new unix should boot automatically."
	if test ! -s /unix.preapx
	then
		cp /unix /unix.preapx
	fi
	sync
	cp /usr/apx5/gen/src/ker860/kernel.cfg.dsp /usr/apx5/gen/src/ker860/kernel.cfg
	chmod 644 /usr/apx5/gen/src/ker860/kernel.cfg
	echo "Now, shutdown and reboot the system..."
else
	echo "The build of the kernel has failed.  You must determine the cause"
	echo "of the failure and take corrective action."
	exit 2
fi
cd /
exit 0
