#! /bin/sh 
#
# Script to check that the system is at a quiet state, and warn the installer
# about memory requirements and a 2.5 NewsPrint prerequisite.  
#
# Check what the run level is and if not "1" then print message.
# Message will not be displayed for diskless client installation

PKG_INSTALL_ROOT=$ROOTDIR
if test $PKG_INSTALL_ROOT = "/"
then
	who -r > /tmp/run$$
	awk '{if ((int)$3 > 1){
       		print ("\n \n")
        	print ("If possible, perform patch installation in single user mode.")
        	print ("If this can not be done, we recommend having the system in as")
        	print ("quiet a state as possible: no users logged on, no user jobs")
        	print ("running.")} }' /tmp/run$$

fi 

#
# Inform the patch installer of memory requirements.
#


echo
echo
echo "If this patch is applied to a system installed with"
echo "the entire configuration, approximately 20 MB of free"
echo "space in /var is required to install using the default"
echo "save option of the installpatch utility."
echo
echo

#
# Check if NewsPrint 2.5 is installed and if it is print message
# informing user that patch 102113 is required.
#

vers=`pkgparam -R $ROOTDIR SUNWsteNP VERSION 2>/dev/null`
if test $vers
then
	if test $vers = "2.5"
	then
		echo "Systems running NeWSprint 2.5 should also apply"
		echo "the NeWSprint patch 102113 if you are printing on"
		echo "a NeWSprint printer.  Patch 102113 prevents a hang"
		echo "from occurring when printing."
	fi
fi
echo
echo
#
# Asks user is they would like to continue.  It will timeout in
# SLEEP_TIME and installation will continue if no response is given.
#


SLEEP_TIME=60
times_up()
{
   exit 0
}

trap 'times_up' ALRM
( sleep $SLEEP_TIME ; kill -ALRM $$ ) &
child_pid=$!

echo "Do you wish to continue this installation {yes or no} [yes]? \\c"
echo "\n(by default, installation will continue in $SLEEP_TIME seconds)"

read Response
while [ 1 ]
do
        case $Response in
                n | no | N | NO | No)
                        kill -9 $child_pid
                        exit 1 ;;
                "" | y | yes | Y | Yes | YES)
                        kill -9 $child_pid
                        exit 0 ;;
                *)  echo "yes or no please. \\c"
                        read Response ;;
        esac
done
~

