c=" %W% dated %G%	Tektronix 8560 Unix"

c=" install - tnix INSTALL file loader                                     "


c=" Assumptions - that /bin/test /usr/bin/version /bin/tr /bin/grep        "
c="                    and /bin/fbr are the real ones.                     "



c="                       |---------------|                                "
c="                       |   is any      |                                "
c="                     N | proc specific | Y                              "
c="               .-------| install file  |-------.                        "
c="               |       | on floppy ?   |       |                        "
c="               |       |---------------|       |                        "
c="               |                               |                        "
c="               |                               |                        "
c="               |                         |-----------|                  "
c="               |                         |   match   |                  "
c="               |                       Y |  current  | N                "
c="          |---------|                .---| processor |---.              "
c="          | generic |                |   |     ?     |   |              "
c="        Y | install | N              |   |-----------|   |              "
c="      .---|  file   |---.            |                   |              "
c="      |   |   on    |   |            |                   |              "
c="      |   | floppy  |   |            |              |---------|         "
c="      |   |   ?     |   |            |              | generic |         "
c="      |   |---------|   |            |            Y | install | N       "
c="      |                 |            |           .--|  file   |--.      "
c="      |                 |            |           |  |   on    |  |      "
c="      |                 |            |           |  | floppy  |  |      "
c="      |                 |            |           |  |    ?    |  |      "
c="      |                 |            |           |  |---------|  |      "
c="      |                 |            |           |               |      "
c="   |---------|   |---------|   |----------|   |---------|   |-------|   "
c="   |   use   |   | extract |   |   use    |   |   use   |   | abort |   "
c="   | generic |   | entire  |   | specific |   | generic |   |-------|   "
c="   | install |   | floppy  |   | install  |   | install |               "
c="   |  file   |   |---------|   |  file    |   |  file   |               "
c="   |---------|                 |----------|   |---------|               "
c=

c="*
   *  Test for the -f flag (meaning don't ask questions
   *"
if /bin/test "\\$1" = "\-f" -o "\\$2" = "\-f" -o "\\$3" = "\-f" \
          -o "\\$4" = "\-f" -o "\\$5" = "\-f" -o "\\$6" = "\-f" \
          -o "\\$7" = "\-f" -o "\\$8" = "\-f" -o "\\$9" = "\-f"
then
:
else
/bin/echo "
Before installing new product software, we recommend that you perform
a dump of your TNIX system to guard against unexpected malfunctions
during the installation.  It is also recommended that you run syschk
to verify the soundness of your filesystem."

while c=c
do
    /bin/echo -n "Do you wish to proceed with the installation? [y/n] "
    read resp
    case $resp in
    y|Y)  break ;;
    n|N)  /bin/echo "Exiting at user request."
          exit 1 ;;
    *)    ;;
    esac
done
fi

/bin/echo 'Checking for required tools...'
for i in /bin/date /bin/fbr /bin/grep /bin/rm /bin/tr /usr/bin/version
do
	if /bin/test -f $i
	then :
	else
		/bin/echo $i is required for \`install\'
		exit 1
	fi
done

: Copy any parameters the user may have provided for INSTALL
p1=$1 ; p2=$2 ; p3=$3 ; p4=$4 ; p5=$5 ; p6=$6 ; p7=$7 ; p8=$8 ; p9=$9

c="*
   *  Make sure we can access the floppy, before continuing.
   *"
until fbr -t >/dev/null 2>&1
do
    echo "Error accessing floppy disk."
    while c=c
    do
        echo -n "Enter y to retry, n to exit "
        read resp
        case $resp in
        y|Y)  break ;;
        n|N)  echo "Exiting at user request."
              exit 1 ;;
        *)    ;;
        esac
    done
done

set `/usr/bin/version`
cpu=$8

case $cpu in
	11/23) ;;
	11/73) ;;
	*) while /bin/test "$cpu" != "11/23" -a "$cpu" != "11/73"
	   do
		/bin/echo -n "Enter processor type - 11/23 or 11/73 "
		read cpu
	   done ;;
esac

installfiles=`/bin/fbr -t |
              /bin/tr ' ' '\012' | /bin/grep '^/tmp/INSTALL'`
install23=`/bin/echo $installfiles |
              /bin/tr ' ' '\012' | /bin/grep '^/tmp/INSTALL.23$'`
install73=`/bin/echo $installfiles |
              /bin/tr ' ' '\012' | /bin/grep '^/tmp/INSTALL.73$'`
installdef=`/bin/echo $installfiles |
              /bin/tr ' ' '\012' | /bin/grep '^/tmp/INSTALL$'`

install=$installdef

case $cpu in
	11/23)	if /bin/test -n "$install23"
		then
		    install=$install23
		elif /bin/test -n "$install73" -a -z "$installdef"
		then
		    /bin/echo "
For cpu $cpu, neither INSTALL nor INSTALL.23 were found.  Since
$install73 is on the disk, this probably indicates either a
corrupted or erroneous installation disk, or one intended specifically
for an 11/73 processor.  Exit (no action)."
		    exit 1
		fi ;;

	11/73)	if /bin/test -n "$install73"
		then
		    install=$install73
		elif /bin/test -n "$install23" -a -z "$installdef"
		then
		    /bin/echo "
For cpu $cpu, neither INSTALL nor INSTALL.73 were found.  Since
$install23 is on the disk, this probably indicates either a
corrupted or erroneous installation disk, or one intended specifically
for an 11/23 processor.  Exit (no action)."
		    exit 1
		fi ;;

	*)	/bin/echo "Assertion failed. cpu=$cpu is not 11/23 or 11/73."
		exit 1 ;;
esac


c="*
   *  record the comment field from the installation disk, with the
   *  date appended
   *"
date=`/bin/date`
fbr -tv >/tmp/ins$$
ed -c /tmp/ins$$ <<!
2,\$d
$
a
$date
.
-
j
w
!


if /bin/test -n "$install"
then
	/bin/echo "Extracting $install from floppy."
	/bin/fbr -x $install
	$install $p1 $p2 $p3 $p4 $p5 $p6 $p7 $p8 $p9
	/bin/rm -f $install
else
	/bin/echo 'Extracting all files from floppy.'
	/bin/fbr -xv
fi


c="*
   *   now that we are through, log the installation
   *"
cat /tmp/ins$$ >>/tek/etc/installs


if /bin/test -f /usr/keywords/mkkeywds
then
	/bin/echo "Creating new keyword file."
	/usr/keywords/mkkeywds
fi

/bin/echo "Installation complete."

