#!/bin/csh -f
#Tag 1024

#    The preceding tag label has to be on line 2 or the IndigoMagic views
#    do not recognize it properly.

# InstallAlias: loads the contents of the ALIAS Software and customizes the user
#           environment so that the package can be run. The ALIAS Software
#           CD-ROM contains a hierarchy of files which includes:
#
#               - Optional system support files
#
#               - Alias V8.0 software
#
#           and 3 install tools:
#
#               - Install       (master install script)
#
#               - InstallAlias  (installs Alias software)
#
#               - InstallTablet (customizes Alias tablet setup)
#
#           and selected other packages that the installer may find
#           interesting.
#
#    The following steps are performed to install the ALIAS software:
#
#    1) Set a default search path:
#
#       The components of the search path are directories that contain tools
#       which are used to load the ALIAS software.
#
#    2) Set the file creation mask (umask) to 022 so that when files are created
#       (i.e.: read off the distribution media), they will be readable by
#       everyone but only writable by the owner.
#
#    3) Verify that the installer is root:
#
#       If the installer is not root, inform them that the Install procedure
#       must be run as root. Prompt them for the root password (via su) and
#       execute InstallAlias in a root subshell. If the installer fails to
#       specify the root password in 3 attempts, ask them to try again later
#       and exit.
#
#    4) The InstallAlias procedure is capable of installing one of seven ALIAS
#       software packages on machines running IRIX 5 or IRIX 6:
#
#           Alias Studio
#           Alias Designer
#           Alias PowerAnimator
#           Alias Animator
#           Alias Web|Animator
#           Alias AutoStudio
#           Alias Render Software
#
#       Before the installation can begin, InstallAlias must be informed which
#       software package is being installed. This can be done in one of two
#       ways:
#
#       If any of the following environment variables are set (by the master
#       Install script), it indicates which software package is to be installed:
#
#           Environment variable | Software Package
#           ---------------------+--------------------
#                STUD3D          | Alias Studio
#                DES3D           | Alias Designer
#                PANIM3D         | Alias PowerAnimator
#                ANIM3D          | Alias Animator
#                WANIM3D         | Alias Web|Animator
#                ASTUD3D         | Alias AutoStudio
#                REND3D          | Alias Render
#
#       If none of the environment variables are set, InstallAlias asks the
#       installer to indicate which software package they wish to install.
#
#       In all cases (studio, designer, power animator, animator, autostudio
#       and render), the software will be installed in a directory named
#       aliasYYMM (where YYMM are the year and month of the release).
#
#       If the machine is running a version of IRIX which is older than
#       IRIX 5.3, the Alias software cannot be installed as it will not
#       function properly.
#
#       The installed Alias software is owned by the superuser (root).
#
#    5) Determine if the installer is a guru. If InstallAlias runs in guru (or
#       advanced) mode, it may ask some detailed questions about how the
#       installation of the ALIAS software should proceed.
#
#       If InstallAlias does not run in guru mode, it will tend to assume some
#       of the more detailed unix things and not ask the installer for their
#       opinion.
#
#       The choice of whether to run in guru mode is indicated by the `-g'
#       flag on the command line. If the flag is present, InstallAlias runs
#       in guru mode.
#
#    6) Determine where InstallAlias will place its working files. Search for
#       a writable temporary directory among the following directories:
#
#           /var/tmp
#           /usr/tmp
#           /tmp
#
#       InstallAlias will place its temporary files in one of these directories.
#
#    7) Determine the location of the Alias CD-ROM:
#
#       If the environment variable ALIAS_CDLOCN is set, it represents the full
#       pathname of the mount point of the Alias CD-ROM. This environment
#       variable is set by the master install script (Install). The Alias
#       software will be installed from the Alias CD-ROM mounted at the location
#       specified by ALIAS_CDLOCN.
#
#       If ALIAS_CDLOCN is not set, InstallAlias asks the installer if they wish
#       to install the software from a CD-ROM. If they say `yes', InstallAlias
#       asks the installer to specify the mount point of the CD-ROM.
#
#       Once, the mount point of the CD-ROM is known ($ALIAS_CDLOCN or installer
#       specified), InstallAlias verifies the contents of the CD-ROM. If the
#       contents of the CD-ROM are valid, the installation continues, else
#       InstallAlias exits with an explanatory error message. After the
#       CD-ROM has been validated, InstallAlias runs `getid -i' to display
#       machine dependent information and asks the installer to compare it
#       against the requirements for Alias software listed in the documentation.
#       The installer should make sure their machine meets the suggested
#       requirements. InstallAlias then asks the installer if they wish to
#       continue with the installation. If they say `yes', the installation
#       continues, else InstallAlias exits.
#
#    8) If InstallAlias is running in guru mode, ask the installer if they
#       wish to perform a client or server mode installation. A server mode
#       install is the same as an old style install; everything is installed
#       on the current machine. If a client mode install is performed, the
#       Alias software is not installed on the current machine. Instead,
#       the script asks for the complete pathname to a previously installed
#       version of Alias software and creates a symbolic link from /usr/aw/alias
#       to that location. All other support files (ftr file, icon files) are
#       installed on the current machine.
#
#       If the Alias software is being installed in client mode, jump to
#       step #13.
#
#    9) Determine the space requirements of the Alias software:
#
#       If the Alias software is being installed in server mode, steps 10
#       through 12 are performed, unless otherwise indicated.
#
#       The Alias software can be broken into 6 pieces, some of which are
#       installed by default in some situations while others are optionally
#       installed in the same or other situations. These pieces are:
#
#           1) Basic Alias software (includes Alias, but not processor dependent
#              renderer products). This represents the Alias Animator, Alias
#              AutoStudio, Alias Designer, Alias PowerAnimator, Alias
#              Web|Animator and Alias Studio software.
#           2) Basic Alias Render software (subset of Basic Alias software)
#           3) Online documentation
#           4) R4000 (mips2) processor based renderer products
#           5) R5000/R10000 (mips4) processor based renderer products
#           6) Open Digital Studio software
#
#       There are also two sets of data files, the CourseWare lessons and 3DCD
#       digital content library, each of which are optionally installed separate
#       from this step. These files are located on a different CD-ROM. Due to
#       the size of the documentation (> 200Mb), the online documentation has
#       been moved to the CD-ROM containing 3DCD so that the user does not have
#       to copy the documentation to their disk.
#
#       Note that only one of 1) or 2) can be installed at any one time.
#
#       If one of Alias Animator, Alias AutoStudio, Alias Designer, Alias
#       PowerAnimator, Alias Web|Animator or Alias Studio are being installed
#       in automatic mode, the following pieces of software will be installed
#       by default:
#   
#           - Basic Alias software
#           - One of the sets of mips2 or mips4 processor based renderer
#             products, whichever is resident to the current machine. If
#             the machine does not have an mips4 based processor, the mips2
#             version of the renderer products will be installed. This
#             applies to processors such as the R8000.
#
#       In addition, the installer will be asked if they wish to install the
#       non-resident set of renderer products. They are useful to install on a
#       server which is servicing a network of SGI workstations which have a
#       mix of processors.
#
#       If the Alias Render software is being installed in automatic mode, the
#       following pieces of software will be installed by default:
#
#           - Basic Alias Render software
#           - One of the sets of mips2 or mips4 processor based renderer
#             products, whichever is resident to the current machine. If
#             the machine does not have an mips4 based processor, the mips2
#             version of the renderer products will be installed. This
#             applies to processors such as the R8000.
#
#       If the Alias Render software is being installed in advanced (or guru)
#       mode, the following pieces of software will be installed by default:
#
#           - Basic Alias Render software
#           - One of the sets of mips2 or mips4 processor based renderer
#             products, whichever is resident to the current machine. If
#             the machine does not have an mips4 based processor, the mips2
#             version of the renderer products will be installed. This
#             applies to processors such as the R8000.
#
#       In addition, the installer will be asked if they wish to install the
#       non-resident set of renderer products. As with the other Alias software,
#       it is useful to install both sets of render products on a server which
#       will be servicing a network of machines. The online documentation is not
#       available to the Alias Render software as it is graphically based and
#       most render engines do not have graphics.
#   
#       An optional piece of Alias software is the Open Digital Studio (ODS)
#       development environment. If anything other than the Alias Render
#       software is being installed, the installer is asked if they wish to
#       install the ODS development environment. If they say `yes', the
#       software is installed. 
#   
#       At the end of this step, a number of flags will have been set which
#       indicate which pieces of software are to be installed.
#   
#   10) Find all filesystems that have sufficient free disk space for the
#       ALIAS software:
#
#       The space requirements for the software depends on which type of
#       software is being installed and which pieces of software are being
#       installed. A set of flags is used to indicate which pieces of software
#       are to be installed. In addition, Install installs the latest version
#       of IRIX licensing software (license_eoe). The size of this software is
#       added to the size of the Alias software to make sure that everything
#       will fit on the machine.
#   
#       The total space requirements for the Alias software is determined by
#       totalling the space requirements of those pieces of software being
#       installed on a machine. The total space requirements are displayed
#       for the installer to see.
#
#       Determine the amount of free disk space on all writable (not a CD-ROM)
#       local (non-NFS) filesystems.
#
#       If there is insufficient disk space for the chosen pieces of software
#       on each of those filesystems, inform the installer of the problem and
#       exit.
#
#   11) Choose the host filesystem and directory for the ALIAS software:
#
#       If only one writable filesystem has sufficient free disk space, it is
#       chosen by default; else inform the installer of the "the writable
#       filesystems with sufficient disk space" and let them choose where the
#       ALIAS software is to be installed ($sftwfs).
#
#       Once it has been determined on what filesystem the ALIAS software is to
#       be installed, ask the installer where the software should be installed
#       on the filesystem.
#
#       Ask the installer if they wish to install the ALIAS software in
#       /<dir>/aliasYYMM, where /<dir> is the name of a directory on a local
#       writable filesystem where the software will be installed:
#
#       If a machine has one or more writable filesystems with sufficient disk
#       space for the Alias software, the value of /<dir> will be the name of a
#       filesystem where the installer wishes to install the software (i.e.:
#       /usr).
#
#       If a machine has one or more writable filesystems, but the root
#       filesystem is the only writable filesystem with sufficient disk space
#       and /usr is a writable filesystem, the value of /<dir> will be /. The
#       installer will have the option of specifying an alternate location for
#       the software or approving its installation at the suggested location.
#
#       If a machine has one writable filesystem (the root filesystem) and it
#       has sufficient disk space for the software, the value of /<dir> will be
#       /usr which is where InstallAlias would like to install the software.
#
#       In all cases, aliasYYMM is a directory indicating that the Alias
#       software is installed here and its release date.
#
#       If the installer doesn't want to install the software in
#       /<dir>/aliasYYMM, ask them where they do want it.
#
#       When the installer specifies a location for the ALIAS software, verify
#       that:
#
#       - the directory is located in the filesystem that the installer approved
#       - the name of the directory is aliasYYMM (for identification purposes)
#
#       If any of these points are not met, InstallAlias warns the installer and
#       asks them to specify a location which matches the criteria.
#
#       Assuming everything goes okay, the shell variable `sftwdir' will contain
#       the pathname of the directory where the ALIAS software will be
#       installed, pending installer approval.
#
#   12) Verify that the home directory for the ALIAS software does not exist:
#
#       The ALIAS software will be loaded in a directory specified by the
#       installer, that ends with aliasYYMM. If this directory already exists
#       (i.e.: if ALIAS software has been installed), InstallAlias will ask the
#       installer for approval to remove the directory and replace it with the
#       ALIAS software on the distribution CD-ROM. If they say `no', explain the
#       situation and exit; else remove the file/directory and continue with the
#       installation.
#
#   13) Verify that the directory /usr/aw exists:
#
#       This step is performed in both client and server mode.
#
#       Now that we know where the software is going to be installed
#       (/<directory>/aliasYYMM for a server mode install or a user specified
#       location for a client mode install), verify that the /usr/aw directory
#       exists. This directory contains a hierarchy of symbolic links
#       and directories, each of which represent a separate Alias/Wavefront
#       product (i.e.: /usr/aw/alias -> /usr/aliasYYMM).
#
#   14) Create a symbolic link between the home of the ALIAS software and
#       /usr/aw/alias (i.e: /usr/aw/alias ->  /usr/aliasYYMM):
#
#       This step is performed in both client and server mode.
#
#       If /usr/aw/alias already exists and is a symbolic link:
#
#           If the target of /usr/aw/alias is the home of the ALIAS software,
#           the link is correct.
#
#           If the target of /usr/aw/alias is not the home of the ALIAS
#           software, and "points" to a directory, ask the installer if they
#           wish to remove the directory.
#
#           If they say `yes', remove the directory and continue with the
#           installation. If they say `no', inform them that they may continue
#           to use the old software (in the directory) by changing the value
#           of ALIAS_LOCATION to the full pathname of the directory.
#
#           Remove the /usr/aw/alias symbolic link.
#
#       If /usr/aw/alias exists and is not a symbolic link:
#
#           Inform the user of it's existence and give them the option to remove
#           it. If they say `no', print an error message which explains the
#           problem and exit; else remove /usr/aw/alias.
#
#       Form a symbolic link from /usr/aw/alias to the home of the ALIAS
#       software:
#
#           /usr/aw/alias -> <remote filesystem>/aliasYYMM   (client mode)
#           /usr/aw/alias -> <local filesystem>/aliasYYMM    (server mode)
#
#   15) If InstallAlias is running in client mode, jump to step #19. If
#       InstallAlias is running in server mode, comtinue with steps 17
#       through 19.
#
#   16) Verify the existence and accessibility ef the home directory which
#       will contain the ALIAS software:
#
#       If the home directory for the ALIAS software does not exist, create it
#       and fix the permissions.
#
#   17) Install the ALIAS software:
#
#       Change directories to the home of the Alias software and extract the
#       software from the Alias CD-ROM (via tar) to disk.
#
#       The software is installed in the same order as the questions were
#       asked at the beginning of the install. Those pieces installed
#       depend on what product you are installing and what you replied
#       to the question(s) of optional software being installed:
#
#           Basic Alias software OR Basic Render software
#           mips2 render products
#           mips4 render products
#           Open Digital Studio (ODS) development software
#
#       After the extraction or "copy" is complete, check the status of the
#       operation to verify that it completed successfully. If an error
#       occurred, inform the installer of the problem and ask them if they
#       wish to try the installation again. If they answer `yes', InstallAlias
#       reattempts the installation; else abort the installation and exit.
#
#   18) Fix the permissions of the ALIAS software so that only the owner (root)
#       may modify the files (remove write permissions for others), but everyone
#       may read them. When tar extracts files from the CD-ROM (via tar), it
#       attempts to restore their original permission modes. The value of the
#       umask has no control on the modes of these files if we are superuser.
#
#   19) Add entries to iconbook:
#
#       Add entries for the following files to the AliasWavefront page of
#       the iconbook:
#
#           /usr/aw/alias/bin/Alias
#           /usr/aw/alias/bin/flipbook
#           /usr/aw/alias/bin/ms3
#           /usr/aw/alias/bin/soundsync
#
#       Verify that each file exists before adding it to the page.
#
#   20) Enable the file command to recognize Alias format files:
#
#       This step is performed in both client and server mode.
#
#       Search /etc/magic for entries which describe Alias format files. The
#       magic file contains a number of definitions which allow the IRIX file
#       command to identify a number of different file formats. If the entries
#       describing Alias format files do not appear to be in the magic file and
#       InstallAlias is running in guru mode, ask the installer if they wish to
#       add the entries to the file. If they say `yes' or InstallAlias is not
#       running in guru mode, the entries are added to the magic file.
#
#   21) Setup render control area:
#
#       In order to support distributed rendering with the Alias software, a
#       render control directory must be created. This directory must be world
#       writable in order to allow any Alias user to write to the directory.
#
#       By default, the render control area will be the directory,
#       /usr/aw/alias/render_control, but customers do have the option of
#       creating a shared area at a later time:
#
#       If the machine has NFS enabled, inform the installer that they may wish
#       to setup a common render control area which is equally accessible from
#       all machines which have NFS enabled. The details for this are in the
#       Alias documentation.
#
#       If InstallAlias is running in client mode, it instructs the installer
#       to ensure that the default render control area exists on the server
#       containing the Alias software.
#
#       If InstallAlias is running server mode, it creates the render control
#       area and makes the directory equally accessible for all users.
#
#   22) If InstallAlias is installing Alias Render software, jump to step #28.
#
#   23) Conditionally enable virtual swap:
#
#       If the machine is running an acceptable operating system (already
#       verified) and the vswap chkconfig option (enable or disable virtual
#       swap) is off, conditionally enable it.
#
#       If InstallAlias is running in guru mode, inform the installer that
#       virtual swap must be enabled in order for the Alias software to
#       function correctly. Ask the installer if they wish to enable virtual
#       swap. If they say `yes' or InstallAlias is not running in guru mode,
#       enable virtual swap.
#
#   24) Conditionally optimize the size of virtual swap:
#
#       If the vswap chkconfig option (virtual swap) is on, conditionally
#       execute the IncreaseVSwap script (/usr/aw/alias/bin/IncreaseVSwap) to
#       verify that the size of virtual swap on this machine has been
#       optimized.
#
#       If InstallAlias is running in guru mode, explain the situation and ask
#       the installer if they wish to customize the size of virtual swap space.
#       If they say `yes' or InstallAlias is not running in guru mode, customize
#       the size of virtual swap space.
#
#   25) Conditionally setup the IRIX Desktop:
#
#       The following files are necessary for the customization of the IRIX
#       software so that it recognizes Alias based files and other
#       Alias|Wavefront utilties:
#
#           /usr/lib/filetype/install/AWEvalView.ftr
#           /usr/lib/filetype/install/Alias3D.ftr
#           /usr/lib/filetype/install/iconlib/AWevalview.closed.fti
#           /usr/lib/filetype/install/iconlib/AWevalview.open.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.MS3.closed.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.MS3.open.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.RRFR.closed.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.RRFR.open.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.SoundSync.closed.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.SoundSync.open.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.anim.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.environment.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.flipbook.closed.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.flipbook.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.flipbook.open.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.light.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.mask.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.oldlight.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.oldsdl.closed.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.oldsdl.open.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.oldwire.closed.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.oldwire.open.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.oldwire.top.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.pix.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.qmexec.bottom.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.qmexec.closed.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.qmexec.open.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.qmfile.bottom.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.qmfile.closed.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.qmfile.open.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.qpexec.bottom.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.qpfile.bottom.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.rrfr.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.sdl.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.shader.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.sset.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.texture.fti
#           /usr/lib/filetype/install/iconlib/Alias3D.wire.fti
#           /usr/lib/filetype/install/iconlib/Alias3D_V7.exec.closed.fti
#           /usr/lib/filetype/install/iconlib/Alias3D_V7.exec.open.fti
#           /usr/lib/filetype/install/iconlib/Alias3D_preV7.exec.bottom.fti
#           /usr/lib/filetype/install/iconlib/Alias3D_preV7.exec.closed.fti
#           /usr/lib/filetype/install/iconlib/Alias3D_preV7.exec.open.fti
#           /usr/lib/filetype/install/iconlib/AliasSPV3.canvas.fti
#           /usr/lib/filetype/install/iconlib/AliasSP_PreV3.canvas.closed.fti
#           /usr/lib/filetype/install/iconlib/AliasSP_PreV3.canvas.open.fti
#
#       They appear in the support system files area of the ALIAS software
#       CD-ROM and define a number of file type rules used by the Indigo
#       Magic software to identify and interact with Alias based files.
#
#       These files are always installed if InstallAlias is running in automatic
#       mode. If InstallAlias is running in guru mode the desktop chkconfig
#       option is turned off, ask the installer if they wish to customize the
#       desktop.
#
#   26) Install icon files:
#
#       There are several icon files, some for 4Dwm and one for mwm (Motif
#       Window Manager):
#
#           /usr/lib/images/Alias.icon
#           /usr/lib/images/DataBrowser.icon
#           /usr/lib/images/EvalView.icon
#           /usr/lib/images/FlipBook.icon
#           /usr/lib/images/RRFR.icon
#           /usr/lib/images/livewire.icon
#           /usr/lib/images/soundsync.icon
#           /usr/include/X11/bitmaps/alias_icon
#
#       These files represent the respective applications when they are
#       minimized (RRFR.icon is for fastrender, livewire.icon for ms3).
#
#       They are always installed.
#
#   27) Conditionally install Alias tablet support:
#
#       Inform the installer that they should install the Alias tablet drivers
#       if they are planning to use tablets with the Alias software. If the
#       Alias software is being installed from CD-ROM, inform the installer
#       that they may install tablet support via the master install script
#       (Install) at the top level of the CD-ROM.
#
#   28) Rename changed system files:
#
#       Go though the "list of saved system files" and rename them to
#       <file>= if they were changed. For example, if the /etc/magic
#       file was modified, the original version will be renamed to
#       /etc/magic=.
#
#   29) Install the Silicon Graphics licensing software:
#
#       Install the correct version of the license_eoe software on the machine.
#       There are three versions of the software, one for IRIX 5.3 machines,
#       one for IRIX 6.2 and the other for IRIX 6.3 machines.
#
#       This software must be installed in all cases as it applies to all
#       Alias|Wavefront software.
#
#   30) Install/Update Alias|Wavefront common software:
#
#       Install/update the Alias|Wavefront common software in /usr/aw/COM. An
#       important piece of this software is the Licenser. It provides a unique
#       licensing system used by all Alias|Wavefront products. The installation
#       of the common software can be done in one of two ways, depending on
#       the installation (client or server).
#
#       When this process is done, one of two setups has to exist:
#
#           /usr/aw/COM -> COM2.0 (a directory)
#           /usr/aw/COM -> COM2.0 -> /nfs/<remote machine>/usr/aw/COM2.0
#
#       in order for the Licenser and Alias software to work correctly.
#
#       If the Alias Render software is being installed, a small subset of
#       the common software which includes the Licenser is installed. If
#       any software besides the Render software is being installed, the
#       full set of common software required by the software (i.e.: Licenser
#       + awxfiles + required DSOs).
#
#   31) If the anthing other than the Alias Render software was installed in
#       server mode, do a little more work in /usr/aw/alias connected with
#       the installation/setup of the common software:
#
#       Create symbolic link from /usr/aw/alias/bin/awxfiles to
#       /usr/aw/COM2.0/bin/awxfiles. If /usr/aw/alias/bin/awxfiles already
#       exists, remove it. This step is not performed if the Render software
#       is being installed.
#
#       Parts of the Alias software require the OpenModel and other libraries
#       to execute. They are located in /usr/aw/COM2.0/lib and have a suffix
#       of ".2" to identify their version. Instead of copying the libraries to
#       the Alias lib directory (/usr/aw/alias/lib), we create symbolic links
#       from the Alias lib directory to the lib directory in /usr/aw/COM2.0. We
#       also drop the ".2" suffix in naming the symbolic links so that ODS
#       (OpenAlias, OpenModel, OpenRender) applications don't notice (or
#       concern themselves) with the new version of the library. For example:
#
#     /usr/aw/alias/lib/libalias_api.so -> /usr/aw/COM2.0/lib/libalias_api.so.2
#
#   32) Search for an FlexLM string for the local machine:
#
#       The Alias CD-ROM contains an encrypted file of precast FlexLM
#       strings with a machine's getid number as the key. Run the findkey
#       program using the getid number as the key. If the program finds a
#       FlexLM string, it is processed by the licensing software, thus
#       allowing the immediate execution of the Alias software. If a FlexLM
#       string is not found, the main Alias executable will inform the user
#       of the situation when it is first executed.
#
#   33) Conditionally setup a demo account to use the Alias software:
#
#       Ask the installer if they wish to setup a demo account to use/demo
#       the Alias software.
#
#       If the installer wants to setup a demo account, execute the setupacct
#       script on the CD-ROM. The script creates a new account or updates
#       an existing account to use the Alias software.
#
#   34) Finish up:
#
#       Remove any working files used during the installation of the ALIAS
#       software. Inform the installer that the ALIAS software has been
#       installed, then exit.

onintr userexit

#    Set the search path

set path = (/usr/bsd /usr/bin /usr/sbin /usr/lbin /bin /etc /sbin)

#    Verify that the installer is root:
#
#    If the installer is not root, inform them that InstallAlias must be run
#    as root. Prompt them for the root password (via su) and execute
#    InstallAlias in a root subshell. If the installer fails to specify the
#    root password in 3 attempts, ask them to try again later and exit.

set whoami = `id | cut -c6-11`
if ("$whoami" != "(root)") then
    echo ""
    echo "In order to install the Alias software, the Install procedure must be run"
    echo "as root. At this time, you may specify the root password to continue with"
    echo "the installation. If your machine does not have a root password, you will"
    echo "not be prompted and the installation will continue. If you don't know the"
    echo "root password, you will have to find someone who does before the software"
    echo "can be installed."
    echo ""

# Determine where InstallAlias is located.

    set pdir = `dirname $0`
    set pfc = `echo $pdir | cut -c1`
    if ("$pfc" == "/") then
        set cdir = $pdir
        set cmd = $0
    else
        set cdir = $cwd
        set cmd = $cdir/$0
    endif
    @ i = 1
    while ($i <= 3)
        su - root -c "$cmd $argv"
        if ($status == 0) exit 0
        @ i++
    end
    echo ""
    echo "Three attempts to specify the root password have failed. Please try again"
    echo "later."
    echo ""
    echo -n "Press <ENTER> to continue: "
    set a = $<
    exit 1
endif

#    Set variables required by InstallAlias:

set awlocn = /usr/aw
set symlink_to_alias = $awlocn/alias # symbolic link to latest Alias software
set symlink_to_beta = $awlocn/aliasbeta

#    Name of install directory which holds the Alias 3D or render software 
#    (i.e.: /usr/aliasYYMM).

set dir = alias9612

#    Locations of software and data files on Alias CD-ROM (pathnames relative
#    to CD-ROM mount point)

set ALDIR = Products/Alias3D
set ALSYSFILES = $ALDIR/sys
set ALIAS = $ALDIR/alias
set FOURK = $ALDIR/4k
set FIVEK = $ALDIR/5k
set ODS = $ALDIR/Other
set INSTDIR = Products/InstBased
set COM2 = COM2.0
set FKEY = Products/Common/findkey
set COM = $awlocn/COM

set errmsg1=""
set errmsg2=""
set mod_files = ""
set RCDIR = render_control

#   Space requirements here (all in megabytes):
#
#   threed_Mbspace : Basic Alias 3D software with no renderer/raytracer
#   tcomspace      : Required COM software for Alias3D software
#   rcomspace      : Required COM software for render software
#   ro_Mbspace     : Basic render only software with no renderer/raytracer
#   fourkrspace    : R4K renderer/raytracer products
#   fivekrspace    : R5K/R10K renderer/raytracer products
#   licspace       : Required license_eoe software

set threed_Mbspace = 175   # Basic Alias 3D software (i.e. studio, no renderer)
set tcomspace = 35         # Size of Alias3D common software (megabytes)
set rcomspace = 3          # Size of render common software (megabytes)
set ro_Mbspace = 15        # Basic render Only software (no renderer)
set ifivefourkrspace = 24  # Megabytes for IRIX 5 R4K renderer products
set fourkrspace = 26       # Megabytes for IRIX 6 R4K renderer products
set fivekrspace = 26       # Megabytes for R5K/R10K renderer products
set odsspace = 41          # Megabytes for ODS development environment
set licspace = 10          # Megabytes for license_eoe software

set DF = "df -k"
set DU = "du -s -k"
set DLR = '$'

umask 022

#    The InstallAlias procedure is capable of installing one of seven ALIAS
#    software packages:
#
#        Alias Studio          (from ALIAS Software CDROM)
#        Alias Designer        (from ALIAS Software CDROM)
#        Alias PowerAnimator   (from ALIAS Software CDROM)
#        Alias Animator        (from ALIAS Software CDROM)
#        Alias Web|Animator    (from ALIAS Software CDROM)
#        Alias AutoStudio      (from ALIAS Software CDROM)
#        Alias Render          (from ALIAS Software CDROM)
#
#    Before the installation can begin, InstallAlias must be informed which
#    software package is being installed. This can be done in one of two
#    ways:
#
#    If any of the following environment variables are set (by the master
#    Install script), it indicates which software package is to be installed:
#
#        Environment variable | Software Package
#        ---------------------+--------------------
#             STUD3D          | Alias Studio
#             DES3D           | Alias Designer
#             PANIM3D         | Alias PowerAnimator
#             ANIM3D          | Alias Animator
#             WANIM3D         | Alias Web|Animator
#             ASTUD3D         | Alias AutoStudio
#             REND3D          | Alias Render
#
#    If none of the environment variables are set, InstallAlias asks the
#    installer to indicate which software package they wish to install.

set STUD = 1
set DES = 2
set PANIM = 3
set ANIM = 4
set WANIM = 5
set ASTUD = 6
set REND = 7

if ($?STUD3D) then
    set choice = $STUD
else if ($?DES3D) then
    set choice = $DES
else if ($?PANIM3D) then
    set choice = $PANIM
else if ($?ANIM3D) then
    set choice = $ANIM
else if ($?WANIM3D) then
    set choice = $WANIM
else if ($?ASTUD3D) then
    set choice = $ASTUD
else if ($?REND3D) then
    set choice = $REND
else
    echo ""
    echo "The Install procedure may be used to install one of seven ALIAS software"
    echo "packages:"
    echo ""
    echo "    $STUD) Alias Studio V8.0"
    echo "    $DES) Alias Designer V8.0"
    echo "    $PANIM) Alias PowerAnimator V8.0"
    echo "    $ANIM) Alias Animator V8.0"
    echo "    $WANIM) Alias Web|Animator V8.0"
    echo "    $ASTUD) Alias AutoStudio V8.0"
    echo "    $REND) Alias Render Software"
    echo ""
    echo -n "Which software package do you wish to install? (1-$REND): "
    while (1)
        set choice = $<
        if ("$choice" !~ [1234567]) then
            echo -n "Please specify a number between 1 and ${REND}: "
        else
            break
        endif
    end
endif

#    In all cases (studio, designer, power animator, animator, web|animator,
#    autostudio and render), the software will be installed in a directory
#    named aliasYYMM (where YYMM are the year and month of the release).

if ($choice == $STUD) then
    set vers = "Studio"
else if ($choice == $DES) then
    set vers = "Designer"
else if ($choice == $PANIM) then
    set vers = "PowerAnimator"
else if ($choice == $ANIM) then
    set vers = "Animator"
else if ($choice == $WANIM) then
    set vers = "Web|Animator"
else if ($choice == $ASTUD) then
    set vers = "AutoStudio"
else if ($choice == $REND) then
    set vers = "Render"
    set render_sftw
endif

#    Determine if the machine is running an acceptable operating system:
#
#    If the machine is running a version of IRIX which is older than IRIX 5.3,
#    the Alias software cannot be installed as it will not run properly in
#    some cases.

set os = `uname -r`
set nos = `echo $os | sed "s/\.//" | cut -c1-2`
if ($nos < 53) then
    echo ""
    echo ""
    echo "The $vers software cannot be installed on this machine because the"
    echo "machine is running an unacceptable version of the operating system (IRIX `uname -r`)."
    echo "The Alias software on the distribution CD-ROM is incompatible with any version"
    echo "of IRIX which is older than IRIX 5.3 and will not function properly on this"
    echo "machine."
    echo ""
    echo ""
    echo -n "Press <ENTER> to continue: "
    set a = $<
    exit
endif

#    if the machine is running IRIX 5.3, display a message which explains
#    that certain aspects of the Alias software may not work with this
#    operating system. Ask them if they wish to continue with the installation.
#    If they say `no', exit gracefully, else continue with the installation.

if ("$os" == "5.3") then
    echo ""
    echo "*************************************************************************"

    echo "        I M P O R T A N T  N O T I C E"

    echo "*************************************************************************"
    echo ""
    echo "THIS MACHINE IS RUNNING IRIX 5.3"
    echo "*********************************"
    echo ""
    echo "The $vers software will load and run under IRIX 5.3 and many"
    echo "hardware configurations (such as Indy, Indigo2 Extreme, etc.) are"
    echo "problem-free in this configuration."
    echo ""
    echo "However, should you encounter an operating system or graphics related"
    echo "problem, the Assist Hotline will only be able to recommend that you"
    echo '"upgrade to IRIX 6.2 including any indicated patches." Assist will'
    echo "still be able to answer questions about the functionality of the"
    echo "package."
    echo ""
    echo "For further information, this message and related information is"
    echo "available in your $vers documentation."
    echo ""
    echo "*************************************************************************"
    echo ""
    echo -n "Do you wish to continue with the installation? (yes/no): "
    while (1)
        set ans = $<
        if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
            echo -n "Please specify yes or no: "
        else
            break
        endif
    end
    if ($ans =~ [Nn][Oo]) goto userexit
endif

#   The Alias CD-ROM contains inst images for the IRIX 5.3, 6.2 and 6.3
#   releases of the FlexLM licensing utilities.
#
#   If the machine is running one of those operating systems, set a flag
#   (do_liceoe) which indicates that the release versions of license_eoe
#   (the FlexLM software) should be installed (see below).

if ("$os" == "5.3" || "$os" == "6.2" || "$os" == "6.3") then
    set do_liceoe
endif

#    Determine which type of cpu is on the machine. This information will be
#    used to determine which version of the Alias powercasters, powertracers,
#    raytracers and renderers will be installed on the machine. If the machine
#    has an mips4 based processor, the mips4 version of the renderer products
#    will be installed. Otherwise, the mips2 version of the renderer products
#    will be installed. This means that for a machine with an R8000 processor,
#    the R4000 version of the renderer products will be installed.
#
#    Some versions of hinv print a separate line for each processor on multi
#    processor machines and this can cause the following test to cack. In
#    order to avoid the error, we only look at the first line of the output
#    of `hinv -t cpu'. All the processors are the same speed, so this test
#    is safe.

set proc = `hinv -t cpu | sed 1q | awk '{ print $3 }'`
if ($proc == "R5000" || $proc == "R8000" || $proc == "R10000") then
    set fivek
else
    set fourk
endif

#    Determine if the installer is a guru:
#
#    If InstallAlias runs in guru mode, it may ask some detailed questions
#    about how the installation of the ALIAS software should proceed. It will
#    try not to assume anything.
#
#    If InstallAlias does not run in guru mode, it will tend to assume some of
#    the more detailed unix things and not ask the installer for their opinion.
#
#    If InstallAlias is called with a `-g' flag, it runs in guru mode.

echo ""
if ($#argv == 1) then
    if ("$1" == "-g") then
        set guru_mode
        echo "Install will install the $vers software in advanced mode."
    endif
endif

if (! $?guru_mode) then
    echo "Install will install the $vers software in automatic mode."
endif

#    Determine where InstallAlias will place its working files. The files will
#    be placed in one of /var/tmp, /usr/tmp or /tmp.

if (-d /var/tmp && -w /var/tmp) then
    set TMPDIR = /var/tmp
else if (-d /usr/tmp && -w /usr/tmp) then
    set TMPDIR = /usr/tmp
else
    set TMPDIR = /tmp
endif
set IOUT = $TMPDIR/tee.$$

#    Find the location of the ALIAS CD-ROM:
#
#    If the environment variable ALIAS_CDLOCN is set, it represents the full
#    pathname of the mount point of the Alias CD-ROM. This environment variable
#    is set by the master install script (Install). The Alias software will be
#    installed from the Alias CD-ROM mounted at the location specified by
#    ALIAS_CDLOCN.
#
#    If ALIAS_CDLOCN is not set, InstallAlias asks the installer to specify
#    the mount point of the CD-ROM.
#
#    Once, the mount point of the CD-ROM is known ($ALIAS_CDLOCN or installer
#    specified, InstallAlias verifies the contents of the CD-ROM. If the
#    contents of the CD-ROM are valid, the installation continues, else
#    InstallAlias exits with an explanatory error message.
#
#    At the end of this step (assuming no errors have occurred), InstallAlias
#    will know the mount point of the CD-ROM player which contains the
#    Alias CD-ROM.

if ($?ALIAS_CDLOCN) then
    set ALIAS_CDPATH = $ALIAS_CDLOCN
else
    echo ""
    echo "Before Install can install the $vers software, it must determine"
    echo "where the ALIAS CD-ROM is located on your machine."

#    If ALIAS_CDLOCN is not set, InstallAlias has to know where the CD-ROM
#    is mounted. InstallAlias determines its mount point and asks the installer
#    if it is the correct location. If they say `no', InstallAlias asks them
#    where the CD-ROM is mounted.

    set pdir = `dirname $0`
    set pfc = `echo $pdir | cut -c1`
    if ("$pfc" == "/") then
        set cdir = $pdir
    else
        set cdir = $cwd
    endif

    echo ""
    echo -n "Is the CD-ROM mounted at $cdir? (yes/no): "
    while (1)
        set ans = $<
        if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
            echo -n "Please specify yes or no: "
        else
            break
        endif
    end
    if ($ans =~ [Yy][Ee][Ss]) then
        set ALIAS_CDPATH = $cdir
    else
        echo ""
        while (1)
            echo -n "Where is the CD-ROM mounted? (please specify a full pathname): "
            set pname = $<
            set ALIAS_CDPATH = ($pname)

#    Verify that the specified mount point is a full pathname (starts with /).

            set pfc = `echo $ALIAS_CDPATH | cut -c1`
            if ("$pfc" != "/") then
                echo ""
                echo "$ALIAS_CDPATH is not a full pathname. Please choose again."
                echo ""
                continue
            endif
            if ($#ALIAS_CDPATH == 1) break
        end
    endif
endif

#    If the ALIAS software is being installed from a CD-ROM, the CD-ROM must
#    have been mounted by the installer at a mount point specified by
#    the installer ($ALIAS_CDPATH).

set almedia = "CD-ROM"
echo ""
echo "Validating the $almedia mounted at $ALIAS_CDPATH ..."

#    Once the mount point of the CD-ROM has been determined, InstallAlias
#    validates it:
#
#    Verify that the CD-ROM mount point specified by the installer exists, it
#    is a directory and the CD-ROM is mounted (actually, the pathname specified
#    by ALIAS_CDPATH contains the proper files to install the Alias software).

if (-e $ALIAS_CDPATH) then
    if (-d $ALIAS_CDPATH) then
        set valid_cd
        foreach adir ($ALSYSFILES $ALIAS)
            if (! -d $ALIAS_CDPATH/$adir) then
                echo ""
                echo "The directory $adir is missing from the CD-ROM."
                unset valid_cd
            endif
        end
        if (! $?valid_cd) then
            echo ""
            echo "Either the CD-ROM is not mounted, the correct CD-ROM is not being used, the"
            echo "CD-ROM is corrupted or the CD-ROM mount point you specified ($ALIAS_CDPATH)"
            echo "is not correct."
            echo ""
            echo "Once you have resolved the problem, attempt the installation again."
            echo ""
            echo -n "Press <ENTER> to continue: "
            set a = $<
            exit
        endif
    else
        echo ""
        echo "The CD-ROM mount point that you specified ($ALIAS_CDPATH) is not a directory."
        echo ""
        echo "Please make sure that the CD-ROM is mounted and the pathname that you specified"
        echo "($ALIAS_CDPATH) is the mount point of the CD-ROM, then attempt the"
        echo "installation again."
        echo ""
        echo -n "Press <ENTER> to continue: "
        set a = $<
        exit
    endif
else
    echo ""
    echo "The CD-ROM mount point specified by the installer ($ALIAS_CDPATH) does not exist."
    echo ""
    echo "Please make sure that the CD-ROM is mounted and/or the pathname specified by"
    echo "the installer is correct, then attempt the installation again."
    echo ""
    echo -n "Press <ENTER> to continue: "
    set a = $<
    exit
endif

#    Now that we know that the Alias software is being installed from a
#    verified CD-ROM, run getid to give the installer some needed information.

echo ""
echo ""
echo "Please compare your machine configuration described below with the minimum"
echo "requirements described in the booklet accompanying your Alias|Wavefront CD-ROM."
echo "Ensure your machine meets the required configuration and suggested operating"
echo "system before continuing with the installation."
echo ""
$ALIAS_CDPATH/$ALIAS/bin/getid -i | sed "s/^/	/"
echo ""
echo -n "Do you wish to continue with the installation? (yes/no): "
while (1)
    set ans = $<
    if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
        echo -n "Please specify yes or no: "
    else
        break
    endif
end
if ($ans =~ [nN][oO]) then
    echo ""
    echo -n "Press <ENTER> to continue: "
    set a = $<
    exit
endif

echo ""
echo "Installing $vers software from a $almedia drive."

#    If we are installing golden software (not beta) and Alias beta software
#    appears to be installed (/usr/aw/aliasbeta is a symbolic link), check
#    for the existence of beta Alias software.

if ($symlink_to_alias != $symlink_to_beta && -l $symlink_to_beta) then
    echo "Looking for beta Alias software ..."
    echo ""

#    Check for beta Alias software:
#
#    If a cut of Alias beta software appears to be installed (/usr/aw/aliasbeta
#    is a symbolic link whose target is a directory), ask the installer if they
#    wish to remove the beta Alias software.
#
#    If they say `yes', remove the software and continue with the installation.
#    If they say `no', inform them that they may continue to use the old
#    software by changing the value of ALIAS_LOCATION to /usr/aw/aliasbeta.

    set target = `ls -l $symlink_to_beta | awk '{print $11}'`
    set pfc = `echo $target | cut -c1`
    if ("$pfc" != "/") then
        set target = $symlink_to_beta:h/$target
    endif

    if ("$target" != "$symlink_to_beta:h/" && -d "$target") then
        echo "Since the $vers software on the ALIAS distribution $almedia is meant"
        echo "to replace the beta Alias software installed in $target, the beta"
        echo "software should be removed. This will provide valuable disk space for"
        echo "further development."
        echo ""
        echo -n "Do you wish to remove $target? (yes/no): "
        while (1)
            set ans = $<
            if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
                echo -n "Please specify yes or no: "
            else
                break
            endif
        end
        if ($ans =~ [Yy][Ee][Ss]) then
            echo ""
            echo "Removing $target ..."
            rm -fr $target

#    Remove the /usr/aw/aliasbeta symbolic link

            echo ""
            echo "Removing $symlink_to_beta ..."
            rm -f $symlink_to_beta
        else
            echo ""
            echo "If you wish to continue using the software in $target, you may do"
            echo "so by setting your ALIAS_LOCATION to $symlink_to_beta. If you have any"
            echo "questions about this, contact Alias|Wavefront Assist for details."
        endif
    endif
endif

if ($?guru_mode) then

#    If InstallAlias is running in guru mode, ask the installer if they
#    wish to perform a client or server mode installation. A server mode
#    install is the same as an old style install; everything is installed
#    on the current machine. If a client mode install is performed, the
#    Alias software is not installed on the current machine. Instead,
#    the script asks for the complete pathname to a previously installed
#    version of Alias software and creates a symbolic link from /usr/aw/alias
#    to that location. All other support files (ftr file, icon files) are
#    installed on the current machine.

    echo ""
    echo ""
    echo "The Install procedure allows you to install the $vers software"
    echo "in one of two environments, server or client."
    echo ""
    echo "If you elect to install the software in server mode, the $vers"
    echo "software and associated support files will be installed on this machine."
    echo ""
    echo "If you elect to install the software in client mode, instead of installing"
    echo "the $vers software on this machine, you will be asked to supply the"
    echo "complete pathname of the Alias software, as installed on a server machine."
    echo "The Install procedure will create a symbolic link from this machine (the"
    echo "client) to the server so that you can run the software across NFS. After"
    echo "creating the link, the install procedure will install those support files"
    echo "which must be present on each machine executing the software."
    echo ""
    echo "Do you wish to install the $vers software in client mode?"
    echo -n "(yes/no): "
    while (1)
        set ans = $<
        if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
            echo -n "Please specify yes or no: "
        else
            break
        endif
    end
    if ($ans =~ [Yy][Ee][Ss]) then
        set clienti
    endif
endif

if ($?clienti) then
    while (1)
        echo ""
        echo "Please specify the full pathname (from this machine) to the previously"
        echo -n "installed Alias software on a server machine: "
        set pname = $<
        set sftwdir = ($pname)

#    Verify that the installer typed something meaningful.

        if ($#sftwdir != 1) continue

#        Verify that the specified location exists and is a directory.

        if (-e $sftwdir) then
            if (-d $sftwdir) then
                break
            else
                echo ""
                echo ""
                echo "It appears that $sftwdir is not a directory."
                echo ""
                echo "Please try again."
            endif
        else
            echo ""
            echo "It appears that $sftwdir does not exist."
            echo ""
            echo "Please try again."
        endif
    end
else

#    The Alias software can be broken into 6 pieces, some of which are
#    installed by default in some situations while others are optionally
#    installed in the same or other situations. These pieces are:
#
#        1) Basic Alias software (includes Alias, but not processor dependent
#           renderer products). This represents the Alias Animator, Alias
#           AutoStudio, Alias Designer, Alias PowerAnimator, Alias Web|Animator,
#           and Alias Studio software.
#        2) Basic Alias Render software (subset of Basic Alias software)
#        3) Online documentation
#        4) mips2 processor based renderer products
#        5) mips4 processor based renderer products
#        6) Open Digital Studio development environment
#
#    There are also two sets of data files, the CourseWare lessons and 3DCD
#    digital content library, each of which are optionally installed separate
#    from this step. These files are located on a different CD-ROM. Due to
#    the size of the documentation (> 200Mb), the online documentation has
#    been moved to the CD-ROM containing 3DCD so that the user does not have
#    to copy the documentation to their disk.
#
#    Note that only one of 1) or 2) can be installed at any one time.
#
#    If one of Alias Animator, Alias AutoStudio, Alias Designer, Alias
#    PowerAnimator, Alias Web|Animator, or Alias Studio are being installed
#    in automatic mode, the following pieces of software will be installed
#    by default:
#
#        - Basic Alias software
#        - One of the sets of mips2 or mips4 processor based renderer
#          products, whichever is resident to the current machine. If
#          the machine does not have an mips4 based processor, the mips2
#          version of the renderer products will be installed. This
#          applies to processors such as the R8000.
#
#    If the same product (or one of the other five) is being installed in
#    advanced (or guru) mode, the following pieces of software will be
#    installed by default:
#
#        - Basic Alias software
#        - One of the sets of mips2 or mips4 processor based renderer
#          products, whichever is resident to the current machine. If
#          the machine does not have an mips4 based processor, the mips2
#          version of the renderer products will be installed. This
#          applies to processors such as the R8000.
#
#    In addition, the installer will be asked if they wish to install the
#    non-resident set of renderer products. They are useful to install on a
#    server which is servicing a network of SGI workstations which may have
#    a mixture of processor types.
#
#    If the Alias Render software is being installed in automatic mode, the
#    following pieces of software will be installed by default:
#
#        - Basic Alias Render software
#        - One of the sets of mips2 or mips4 processor based renderer
#          products, whichever is resident to the current machine. If
#          the machine does not have an mips4 based processor, the mips2
#          version of the renderer products will be installed. This
#          applies to processors such as the R8000.
#
#    If the Alias Render software is being installed in advanced (or guru)
#    mode, the following pieces of software will be installed by default:
#
#        - Basic Alias Render software
#        - One of the sets of mips2 or mips4 processor based renderer
#          products, whichever is resident to the current machine. If
#          the machine does not have an mips4 based processor, the mips2
#          version of the renderer products will be installed. This
#          applies to processors such as the R8000.
#
#    In addition, the installer will be asked if they wish to install the
#    non-resident set of renderer products. As with the other Alias software,
#    it is useful to install both sets of render products on a server which
#    will be servicing a network of machines. The online documentation is not
#    available to the Alias Render software as it is graphically based and most
#    render engines do not have graphics.
#
#    An optional piece of Alias software is the Open Digital Studio (ODS)
#    development environment. If anything other than the Alias Render software
#    is being installed, the installer is asked if they wish to install the
#    ODS development environment. If they say `yes', the software is installed.
#
#    At the end of this step, a number of flags will have been set which
#    indicate which pieces of software are to be installed.

    if ($?guru_mode) then
        echo ""
        echo ""
        echo "Normally only the versions of the powercaster, powertracer, raytracer, and"
        echo "renderer appropriate for the processor of your machine are installed. If you"
        echo "plan to use this machine as a server, from which machines with other"
        echo "processors will execute the Alias software, you may wish to install all"
        echo "versions of the powercaster, powertracer, raytracer, and renderer on your"
        echo "machine."
        echo
        echo "Currently only the "
        echo ""
        if ($?fivek) then
            echo -n "	IRIX 5.3 (O32) and IRIX 6.2 (N32) R5000/R10000 "
            @ xxx = $ifivefourkrspace + $fivekrspace
            echo "($xxx megabytes)"
        else
            echo -n "	IRIX 5.3 (O32) and IRIX 6.2 (N32) R4000 "
            @ xxx = $ifivefourkrspace + $fourkrspace
            echo "($xxx megabytes)"
        endif
        echo
        echo "processor versions of the powercaster, powertracer, raytracer, and renderer"
        echo "will be installed."
        echo ""
        echo "Do you wish to install all versions of the powercaster, powertracer, raytracer"
        echo -n "and renderer? (yes/no): "
        while (1)
            set ans = $<
            if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
                echo -n "Please specify yes or no: "
            else
                break
            endif
        end
        if ($ans =~ [Yy][Ee][Ss]) then
            set allren
            set fivek
            set fourk
        endif
        echo ""
    endif

    if (! $?render_sftw) then
        echo ""
        echo ""
        echo "An optional piece of software which you may be interested in installing"
        echo "with the $vers software is the Open Digital Studio (ODS) software."
        echo "It consists of OpenAlias, OpenModel, OpenRender and some shared files."
        echo ""
        echo "OpenAlias is a product which allows you to add new functionality to Alias"
        echo "through a plug-in architecture."
        echo ""
        echo "OpenModel is a set of libraries and header files which allow you to write"
        echo "applications which can read, write, and modify Alias wire files."
        echo ""
        echo "OpenRender allows users to write C code so that they can write their own"
        echo "shader, texture and light files."
        echo ""
        echo "* These directories and files are of use only to programmers. If you are not"
        echo "* going to be programming with any of the above, then you don't need to"
        echo "* install this material. You will still be able to use plugins that have"
        echo "* already been written (there are some useful examples which will be"
        echo "* installed by default)."
        echo ""
        echo -n "Do you wish to install the Open Digital Studio software? (yes/no): "
        while (1)
            set ans = $<
            if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
                echo -n "Please specify yes or no: "
            else
                break
            endif
        end
        if ($ans =~ [Yy][Ee][Ss]) then
            set inst_ods
        else
            echo ""
            echo "If you later decide to install the ODS software, the following"
            echo "instructions may be used to do so:"
            echo ""
            echo "      Insert the $vers distribution CD-ROM into the CD-ROM drive"
            echo "      and mount it:"
            echo ""
            echo "              login root"
            echo "              cd <mount point of CD-ROM>/$ODS"
            echo "              cp -r ODS $symlink_to_alias"
            echo ""
        endif

        echo ""
        echo ""
        echo "There is a set of online documentation for the $vers software"
        echo "available on the Alias|Wavefront 3DCD CD-ROM. Due to its large size"
        echo "(> 200 megabytes), it is not included on this CD-ROM. The install"
        echo "procedure for the online documentation allows you to avoid copying the"
        echo "documentation files to disk. Instead, they may be accessed directly from"
        echo "the Alias|Wavefront 3DCD CD-ROM. See the Alias|Wavefront 3DCD CD-ROM"
        echo "booklet for more details."
    endif

    echo ""
    echo ""
    echo "Computing total disk space requirements for $vers software ..."

#    The variable INSFTW represents a list of files to install from the
#    Alias software on the distribution media. If the software is being
#    installed from CD-ROM and this variable has a value of "." (as is
#    the case when full Alias software is installed), all files are
#    installed, else only those files listed by the variable are installed.
#    Note if the render software is being installed from a CD-ROM, INSFTW
#    will not include a list of powercaster, powertracer, raytracer or
#    renderer executables as they are installed separately.

#    Determine space requirements for the Alias software:
#
#    The space requirements for the software depends on which type of software
#    is being installed and which pieces of software are being installed. A
#    set of flags is used to indicate which pieces of software are to be
#    installed.
#
#    The total space requirements for the Alias software is determined by
#    totalling the space requirements of those pieces of software being
#    installed on a machine.

    if ($?render_sftw) then

#    If render software is being installed INSFTW needs to be set to those
#    files which comprise a render-only install.

        set INSFTW = ".cut .cshrc .login .AliasPrefs .Xresources .4Dwmrc .mwmrc bin/{IncreaseVSwap,alias_render_demon,beep,convert,findit,fstats,gamma,get_alias_variable,getid,pixdiff,powercaster,powertracer,raytracer,renderer,renderit,setupacct,skd} etc/{acct,skd}"

        @ alias_reqd_Mbspace = $ro_Mbspace + $rcomspace
        set comspace = $rcomspace
    else
        set INSFTW = "."
        @ alias_reqd_Mbspace = $threed_Mbspace + $tcomspace
        set comspace = $tcomspace
    endif

#    If the mips2 and/or mips4 versions of the powercaster, powertracer,
#    raytracer and renderer executables are being installed, add their disk
#    space requirements to the required disk space total for the basic Alias
#    software. This total is the amount of disk space required to install
#    the software.

    if ($?fourk) then
        @ alias_reqd_Mbspace += $fourkrspace
    endif

    if ($?fivek) then
        @ alias_reqd_Mbspace += $fivekrspace
    endif

#    If the ODS software is being installed, add its disk space
#    requirement to the grand total.

    if ($?inst_ods) then
        @ alias_reqd_Mbspace += $odsspace
    endif

#    Inform the installer how much disk space the software will require.

    echo ""
    echo "The $vers software requires approximately $alias_reqd_Mbspace megabytes of disk"
    echo "space."
    echo ""

#    If the licensing software (license_eoe) needs to be installed, check
#    that /usr has enough potential free disk space for it. Also add the size
#    of the licensing software to the size of the Alias software to make sure
#    everything will fit on the machine.

    if ($?do_liceoe) then
        @ lic_reqd_kbspace = $licspace * 1024
        set usrdf = `$DF /usr | tail -1 | awk '{ print $5 }'`
        if ($usrdf <= $lic_reqd_kbspace) then
            echo ""
            echo "There is not enough free disk space in the /usr filesystem for the required"
            echo "license support software. This software requires approximately $licspace megabytes of"
            echo "space. Please free sufficient disk space in /usr and attempt the installation"
            echo "again. Consider removing any old software to free sufficient disk space."
            echo "If you are unable to find enough space, ask Alias|Wavefront Assist for"
            echo "assistance."
            echo ""
            echo -n "Press <ENTER> to continue: "
            set a = $<
            exit
        endif
        @ alias_reqd_Mbspace += $licspace
    endif

#    Find all filesystems that have enough disk space for the ALIAS software.
#    If none of the local filesystems have sufficient free disk space, inform
#    the user of the situation and exit.

    @ alias_reqd_kbspace = $alias_reqd_Mbspace * 1024

#    Find all local filesystems (sorted to ensure / is last). Note that
#    we check for both Extent (type efs) and Xfs (type xfs) filesystems.

    set local_fsys = `$DF | awk '$2 == "efs" || $2 == "xfs" {print $7}' | sort -r`

    unset fsystems

#    Inspect all local filesystems on the machine for sufficient space for
#    the Alias software:
#
#    If a filesystem is writable (not a CD-ROM) and has sufficient disk space,
#    it is a candidate filesystem for the installation of the Alias software.
#
#    Also compile a list of all writable filesystems (i.e.: not /CDROM) which
#    is used later.

    set wlocal_fsys = ()
    @ in = 1
    while ($in <= $#local_fsys)
        set lfs = $local_fsys[$in]
        if (-w $lfs) then
            set wlocal_fsys = ($lfs $wlocal_fsys)
            set fsys_ds = `$DF $lfs | awk '$2 == "efs" || $2 == "xfs" {print $5}'`
            if ($fsys_ds > $alias_reqd_kbspace) then
                if ($?fsystems) then
                    set fsystems = ($lfs $fsystems)
                else
                    set fsystems = $lfs
                endif
            endif
        endif
        @ in++
    end

#    At this point, we have 3 important variables:
#
#    local_fsys:  list of local filesystems (in reverse order)
#    wlocal_fsys: list of writable local filesystems
#    fsystems:    list of writable local filesystems with sufficient
#                 disk space for the Alias software. If there are no
#                 such filesystems, this list is not set ($?fsystems == 0).

    if (! $?fsystems) then
        echo ""
        echo "There are no filesystems with sufficient disk space for the $vers"
        echo "software (requires approx $alias_reqd_Mbspace megabytes). Please free sufficient disk space"
        echo "and attempt the installation again. Consider removing any old software to"
        echo "free sufficient disk space. If you are unable to find enough space, ask"
        echo "Alias|Wavefront Assist for assistance."
        echo ""
        echo -n "Press <ENTER> to continue: "
        set a = $<
        exit
    endif

#    Determine the filesystem on which to install ALIAS:
#
#    If only one filesystem has sufficient free disk space, it is chosen by
#    default; else inform the installer of the "the filesystems with sufficient
#    disk space" and let them choose.

    if ($#fsystems != 1) then
        echo ""
        echo "The filesystems with sufficient disk space are:"

        while (1)
            echo ""
            @ index = 1
            while ($index <= $#fsystems)
                echo $fsystems[$index] | sed "s/^/    /"
                @ index++
            end
            echo ""
            while (1)
                echo -n "Please enter your choice: "
                set pname = $<
                set sftwfs = ($pname)
                if ($#sftwfs == 1) break
            end
            @ index = 1
            @ found = 0
            while ($index <= $#fsystems && $found == 0)
                if ("$fsystems[$index]" == "$sftwfs") then
                    @ found++
                else
                    @ index++
                endif
            end
            if ($found != 0) break
            echo ""
            echo "$sftwfs is not a valid choice. Please choose one of:"
        end
    else
        set sftwfs = $fsystems
        echo ""
        echo "The only filesystem with sufficient disk space for the $vers software"
        echo "is $sftwfs."
    endif

#    If the Alias software will be installed on the root filesystem, determine
#    where on the filesystem it can be installed. InstallAlias would like to
#    install it in /usr (the directory, not the filesystem). If this is not
#    possible (/usr is a filesystem with insufficient space for the Alias
#    software), it will will have to installed somewhere else on the root
#    filesystem (i.e. /u).

    if ("$sftwfs" == "/") then
        set swstr = "/usr"
        if ($#wlocal_fsys > 1) then

#    InstallAlias would like to install the Alias software in /usr. If there
#    is more than one local filesystem on the machine and one of them in not
#    /usr, the software can be installed there. This ignores the case where
#    /usr is a read-only local filesystem, but I've never seen that happen
#    (yet!).

            @ i = 1
            while ($i <= $#wlocal_fsys)
                if ("$wlocal_fsys[$i]" == "/usr") then
                    set swstr = ""
                    break
                endif
                @ i++
            end
        else
            echo ""
            echo "Your machine only has one filesystem ($sftwfs). This filesystem includes the $swstr"
            echo "directory which is where Install would like to install the $vers"
            echo "software. You may choose to install the software at any location on the"
            echo "filesystem."
        endif
    else
        set swstr = $sftwfs
    endif

#    Once it has been determined on what filesystem the ALIAS software is to be
#    installed ($sftwfs), ask the installer where the software should be
#    installed on the filesystem.

    echo ""
    echo "The $vers software will be installed in the $sftwfs filesystem in a"
    echo "directory whose pathname ends with $dir; for example $swstr/$dir"
    echo -n "or $swstr/u/$dir"
    if ("$swstr" == "") then
        echo " (if /u is not a filesystem)."
    else
        echo "."
    endif

#    Ask the installer if they wish to install the ALIAS software in
#    /<dir>/aliasYYMM, where /<dir> is the name of a directory on a local
#    filesystem where the software will be installed:
#
#    If a machine has one filesystem (the root filesystem) and it has sufficient
#    disk space for the software, the value of /<dir> will be /usr which is
#    where InstallAlias would like to install the software.
#
#    If a machine has one or more filesystems with sufficient disk space for
#    the Alias software, the value of /<dir> will be the name of a filesystem
#    where the installer wishes to install the software (i.e.: /usr).
#
#    and aliasYYMM is a directory indicating the Alias software and its release
#    date.
#
#    If they doesn't want to install the software in /<dir>/aliasYYMM, ask them
#    where they do want it.

    set sftwdir = $swstr/$dir
    echo ""
    echo "Do you wish to install the $vers software in"
    echo -n "$sftwdir? (yes/no): "

    while (1)
        set ans = $<
        if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
            echo -n "Please specify yes or no: "
        else
            break
        endif
    end

    if ($ans =~ [nN][oO]) then
        while (1)
            unset bad_root bad_suffix root_fs
            echo ""
            echo "Where do you wish to install the $vers software? (please specify a"
            echo -n "full pathname): "
            set pname = $<
            set sftwdir = ($pname)

#    Verify that the installer typed something meaningful.

            if ($#sftwdir != 1) continue

#    When the installer specifies a location for the ALIAS software, verify
#    that:
#
#    - the directory is located in the filesystem that the installer approved
#    - the name of the directory is aliasYYMM (for identification purposes)
#
#    If any of these points are not met, InstallAlias warns the installer and
#    asks them to specify a location which matches the criteria.
#
#    Assuming everything goes okay, the shell variable sftwdir will contain
#    the pathname of the directory where the ALIAS software will be installed,
#    pending installer approval.

#    Verify that the specified location is a full pathname (starts with /).
#    If this is not done here, root_fs will be incorrectly set to / below.

            set pfc = `echo $sftwdir | cut -c1`
            if ("$pfc" != "/") then
                echo ""
                echo "$sftwdir is not a full pathname. Please choose again."
                continue
            endif

            @ i = 1
            while ($i <= $#local_fsys)
                set lfs = $local_fsys[$i]
                set mtch = `echo $sftwdir/ | grep "^$lfs/"`
                if ($#mtch) then
                    set root_fs = $lfs
                    break
                endif
                @ i++
            end
            if (! $?root_fs) set root_fs = "/"

            if ("$root_fs" != "$sftwfs") set bad_root

            set suffix = $sftwdir:t
            if ("$suffix" != $dir) set bad_suffix
            if ($?bad_root || $?bad_suffix) then
                echo ""
                echo ""
                echo "$sftwdir is an invalid choice for the location of the"
                echo "$vers software."
                if ($?bad_root) then
                    echo ""
                    if ($#fsystems != 1) then
                        echo "Since you have chosen to install the software on $sftwfs, you must specify a"
                        echo "location on that filesystem."
                    else
                        echo "Since $sftwfs is the only filesystem with sufficient disk space, you must"
                        echo "specify a location on that filesystem."
                    endif
                endif
                if ($?bad_suffix) then
                    echo ""
                    echo "For the purpose of identification, please specify a location whose pathname"
                    echo "ends with $dir."
                endif
            else
                break
            endif
        end

#    Once the pathname of the eventual location of the ALIAS software has been
#    agreed upon ($sftwdir), ask the installer if it is okay to continue with
#    the installation. If they say `yes' , continue; else abort the
#    installation.

        echo ""
        echo "Proceeding to install the $vers software in $sftwdir."
        echo -n "Continue with the installation? (yes/no): "

        while (1)
            set ans = $<
            if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
                echo -n "Please specify yes or no: "
            else
                break
            endif
        end
        if ($ans =~ [nN][oO]) goto userexit
    endif

#    Verify that the home directory for the ALIAS software does not exist. If
#    it exists, inform the user of its existence and how much disk space it
#    occupies, then give them the option to remove it. If they say `no',
#    explain the situation and exit; else remove the file/directory. Note that
#    running `du' on a file does not provide any disk space information and
#    `ls -l' must be used instead.

    if (-e $sftwdir) then
        if (-d $sftwdir) then
            set al_sp = `$DU $sftwdir | awk '{print $1}'`
            set ftype = directory
        else
            set al_sp = `ls -l $sftwdir | awk '{printf "%.2f", $5 / 1024}'`
            set ftype = file
        endif
        echo ""
        echo ""
        echo "The $ftype $sftwdir exists and contains $al_sp kilobytes. It is"
        echo "strongly recommended that this be removed and then replaced with the"
        echo "$vers software on the distribution $almedia."
        echo ""
        echo "If this $ftype is not removed (or renamed), the $vers software"
        echo "cannot be installed in the location that you specified and the installation"
        echo "will be discontinued."
        echo ""
        echo -n "Do you wish to remove the old $sftwdir $ftype? (yes/no): "
        while (1)
            set ans = $<
            if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
                echo -n "Please specify yes or no: "
            else
                break
            endif
        end
        if ($ans =~ [nN][oO]) then
            set errmsg1 = "$sftwdir must be removed (or renamed) for the installation to succeed."
            goto baderr
        endif
        echo ""
        echo "Removing $sftwdir."
        rm -fr $sftwdir
    endif
endif

#    Now that we know where the software is going to be installed
#    (/<directory>/aliasYYMM for a server mode install or a user specified
#    location for a client mode install), verify that the /usr/aw directory
#    exists. This directory contains a hierarchy of symbolic links
#    and directories, each of which represent a separate Alias/Wavefront
#    product.

if (-e $awlocn) then
    if (! -d $awlocn) then
        set al_sp = `ls -l $awlocn | awk '{printf "%.2f", $5 / 1024}'`
        echo ""
        echo ""
        echo "The file $awlocn exists and contains $al_sp kilobytes. It is"
        echo "strongly recommended that this be removed and then replaced with the"
        echo "directory in which the $vers software will be installed."
        echo ""
        echo "If this file is not removed (or renamed), the $vers software"
        echo "cannot be installed."
        echo ""
        echo -n "Do you wish to remove the old $awlocn file? (yes/no): "
        while (1)
            set ans = $<
            if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
                echo -n "Please specify yes or no: "
            else
                break
            endif
        end
        if ($ans =~ [nN][oO]) then
            set errmsg1 = "$awlocn must be removed (or renamed) for the installation to succeed."
            goto baderr
        endif
        echo ""
        echo "Removing $awlocn."
        rm -fr $awlocn
    endif
endif

if (! -d $awlocn) then
    echo ""
    echo "Creating $awlocn directory for the installation of the $vers software."
    mkdir -m 755 $awlocn
endif

#    Attempt to form a symbolic link between the home of the ALIAS software
#    and /usr/aw/alias (i.e: /usr/aw/alias -> /usr/aliasYYMM [server mode]
#    or /usr/aw/alias -> <specified location> [client mode]):
#
#    If /usr/aw/alias is a symbolic link and its target is the home of the
#    ALIAS software, the link is correct. 
#
#    Note that /usr/aw/alias may be a symbolic link to a relative pathname. If
#    so (no leading slash), prepend the root directory of symlink_to_alias
#    (/usr) to the pathname to determine the full pathname of the link.

set link_usr_alias
if (-l $symlink_to_alias) then
    set target = `ls -l $symlink_to_alias | awk '{print $11}'`
    set pfc = `echo $target | cut -c1`
    if ("$pfc" != "/") then
        set target = $symlink_to_alias:h/$target
    endif
    if ("$target" == "$sftwdir") unset link_usr_alias
endif

#    This code is executed if a symbolic link from /usr/aw/alias to the home of
#    the ALIAS software does not exist:
#
#    If /usr/aw/alias exists, inform the user of its existence and the disk
#    space that it occupies, then give them the option to remove it. If they
#    respond negatively, print an error message which explains the problem and
#    exit; else remove /usr/aw/alias and form a symbolic link from
#    /usr/aw/alias to the home of the ALIAS software.
#
#    The (-e <fname> || -l <fname>) is needed here due to a csh bug:
#
#        Let <fname> be a symbolic link to a non-existent file. If you test
#        <fname> with "-e", it seems to do a stat() which fails because the
#        target of the symlink (non-existent) does not exist. If you test
#        <fname> with "-l", it does an lstat() which succeeds because lstat()
#        examines the symlink and not the target of the symlink.

if ($?link_usr_alias) then
    if (-e $symlink_to_alias || -l $symlink_to_alias) then
        echo ""
        echo ""
        if (-l $symlink_to_alias) then
            echo "Looking for old Alias software ..."
            echo ""

#    At this point, we know that /usr/aw/alias is a symbolic link whose target
#    is not the home directory of the ALIAS software (as it should be).
#
#    If the target of /usr/aw/alias is not null ($target == "/usr/" if
#    /usr/aw/alias "points" to null) and is a directory, ask the installer
#    if they wish to remove the old software.
#
#    If they say `yes', remove the software and continue with the installation.
#    If they say `no', inform them that they may continue to use the old
#    software by changing the value of ALIAS_LOCATION to the full pathname
#    of the directory.

            if ("$target" != "$symlink_to_alias:h/" && -d "$target") then
                echo "Since the $vers software on the ALIAS distribution $almedia is meant"
                echo "to replace the Alias software installed in $target, the old"
                echo "software should be removed. This will provide valuable disk space for"
                echo "further development."
                echo ""
                echo -n "Do you wish to remove $target? (yes/no): "
                while (1)
                    set ans = $<
                    if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
                        echo -n "Please specify yes or no: "
                    else
                        break
                    endif
                end
                if ($ans =~ [Yy][Ee][Ss]) then
                    echo ""
                    echo "Removing $target ..."
                    rm -fr $target
                else
                    echo ""
                    echo "If you wish to continue using the software in $target, you may do so"
                    echo "by setting your ALIAS_LOCATION to $target. If you have any questions"
                    echo "about this, contact Alias|Wavefront Assist for details."
                endif
            endif

#    Remove the /usr/aw/alias symbolic link

            echo ""
            echo "Removing $symlink_to_alias ..."
            rm -f $symlink_to_alias
        else

#    In this case, /usr/aw/alias is anything except a symbolic link (directory,
#    file, <etc>), but this procedure requires that it be a symbolic link to
#    the home directory of the ALIAS software. Unlike the previous section
#    of code, the amount of disk space occupied by /usr/aw/alias is computed and
#    reported to the user. Note that running `du' on a file does not provide
#    any disk space information and `ls -l' must be used instead.

            if (-d $symlink_to_alias) then
                set al_sp = `$DU $symlink_to_alias | awk '{print $1}'`
                set ftype = directory
            else
                set al_sp = `ls -l $symlink_to_alias | awk '{printf "%.2f",$5 / 1024}'`
                set ftype = file
            endif
            echo ""
            echo "The $ftype $symlink_to_alias exists and contains $al_sp kilobytes. The purpose"

#    Have to enclose string in double quotes so that `$symlink_to_alias'
#    expands.

            echo -n "of $symlink_to_alias"
            echo ' is to "point" to the latest version of ALIAS software that'
            echo "has been installed on this machine, thus it must be removed (or renamed)"
            echo "for the installation to continue."
            echo ""
            echo -n "Do you wish to remove $symlink_to_alias? (yes/no): "
            while (1)
                set ans = $<
                if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
                    echo -n "Please specify yes or no: "
                else
                    break
                endif
            end
            if ($ans =~ [nN][oO]) then
                set errmsg1 = "$symlink_to_alias must be removed (or renamed) for the installation to succeed."
                goto baderr
            endif
            echo ""
            echo "Removing $symlink_to_alias ..."
            rm -fr $symlink_to_alias
        endif
    endif

    echo ""
    echo "Creating symbolic link from $symlink_to_alias to $sftwdir."
    ln -s $sftwdir $symlink_to_alias
    if ($status != 0) then
        echo ""
        set errmsg1 = "Cannot form symbolic link from $symlink_to_alias to $sftwdir"
        goto baderr
    endif
endif

#    If this is a client mode install, we make no attempt to install any
#    parts of the Alias software since it's already installed on the server.
#
#    If this is a server mode install, we install all pieces of the software
#    (+ support files) on the local machine.

if (! $?clienti) then

#    If the home directory for the ALIAS software does not exist, create it.

    if (! -d $sftwdir) then
        echo ""
        echo "Creating directory for the $vers software."
        mkdir -m 755 -p $sftwdir
        if ($status != 0) then
            set errmsg1 = "Error creating $vers directory ($sftwdir)"
            goto baderr
        endif
    endif

    chdir $sftwdir
    while (1)

#    If the Alias software is being installed from CD-ROM, "copy" the software
#    (via tar) from the appropriate directories on the CD-ROM.

        echo ""
        echo "Extracting $vers from the CD-ROM ... This may take awhile."
        echo ""
        (chdir $ALIAS_CDPATH/$ALIAS;tar cf - $INSFTW) | tar xvof -
        set st = $status
        if ($st != 0) then
            echo ""
            echo "Error installing basic Alias software."
        endif

#    If the R4000 versions of the powercaster, powertracer, raytracer and
#    renderer are flagged to be installed, do so. All versions of the 4K
#    renderers are installed on all machines. On 6.2 machines this allows
#    us to use the O32 versions if the N32 system libraries are not installed.
#    On 5.3 we install both versions in case the customer later upgrades to 6.2.

        if ($?fourk && $st == 0) then
            (chdir $ALIAS_CDPATH/$FOURK;tar cf - .) | tar xvof -
            set st = $status
            if ($st != 0) then
                echo ""
                echo "Error installing Alias R4000 renderer products."
            endif
        endif

#    If the mips4 versions of the powercaster, powertracer, raytracer and
#    renderer are flagged to be installed, do so.

        if ($?fivek && $st == 0) then
            if (! $?fourk) then
                (chdir $ALIAS_CDPATH/$FOURK;tar cf - bin/*.i5.*) | tar xvof -
            endif
            (chdir $ALIAS_CDPATH/$FIVEK;tar cf - .) | tar xvof -
            set st = $status
            if ($st != 0) then
                echo ""
                echo "Error installing Alias R5000/R10000 renderer products."
            endif
        endif

#    If the ODS software is to be installed, do so.

        if ($?inst_ods && $st == 0) then
            (chdir $ALIAS_CDPATH/$ODS;tar cf - .) | tar xvof -
            set st = $status
            if ($st != 0) then
                echo ""
                echo "Error installing Open Digital Studio software."
            endif
        endif

#    If the CD-ROM was read successfully, break out of the loop and
#    continue with the installation.

        if ($st == 0) break

        echo ""
        echo "The $vers software was not read correctly."
        echo ""

#    If the CD-ROM was not read correctly, inform the user of the problem and
#    ask them if they wish to try to install the software again.

        echo ""
        echo "It appears that there was a problem in reading the $almedia. You may have to"
        echo "attempt it 2 or 3 times before you're finally successful."
        echo ""
        echo -n "Do you wish to try reading the $almedia again? (yes/no): "

        while (1)
            set ans = $<
            if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
                echo -n "Please specify yes or no: "
            else
                break
            endif
        end
        if ($ans =~ [nN][oO]) goto userexit
    end

#    Fix the permissions of the ALIAS software so that only the owner may
#    modify the files (remove write permissions for others), but everyone
#    may read them. When tar "copies" the files from CD-ROM (via tar), it
#    attempts to restore their original permission modes. The value of the
#    umask has no control on the modes of these files if we are superuser.

    echo ""
    echo ""
    echo "Fixing permissions of the $vers software."
    chmod -R go-w+r,u+rw $sftwdir >& /dev/null
endif

#    Now that the Alias software has successfully been installed, if this
#    is not a render-only installation, add icons to the Alias|Wavefront
#    page of the iconbook for the following executables. Remove any old
#    entries for the same executables first to avoid duplicate entries in
#    the iconbook:
#
#        /usr/aw/alias/bin/Alias
#        /usr/aw/alias/bin/flipbook
#        /usr/aw/alias/bin/ms3
#        /usr/aw/alias/bin/soundsync

if (! $?render_sftw && -x /usr/sbin/iconbookedit) then
    echo ""
    echo "Adding executables to iconbook ..."
    foreach f (Alias flipbook ms3 soundsync)
        set fn = $symlink_to_alias/bin/$f
        if (-x $fn) then
            iconbookedit -remove "Category:File Name:${fn}" -syspage AliasWavefront
            iconbookedit -add "Category:File Name:${fn}" -syspage AliasWavefront
        endif
    end
endif

#    Search /etc/magic for entries which describe Alias format files. The
#    magic file contains a number of definitions which allow the file command
#    to identify a number of different file formats. If the entries do not
#    appear to be in the magic file and InstallAlias is running in guru mode,
#    ask the installer if they wish to add the entries to the file. If they say
#    `yes' or InstallAlias is not running in guru mode, the entries are added to
#    the magic file after making a backup copy of the original file.

set MAGIC = /etc/magic
set aff = `grep "^#[ 	][ 	]*Alias format files:${DLR}" $MAGIC`
if ("$aff" == "") then
    echo ""
    echo ""
    echo -n "The file $MAGIC contains a number of"
    echo ' "definitions" which allow the file'
    echo "command to identify a number of different file formats."
    set mod_mfile
    if ($?guru_mode) then
        echo ""
        echo "Do you wish to add entries to the magic file which describe Alias format"
        echo -n "files? (yes/no): "
        while (1)
            set ans = $<
            if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
                echo -n "Please specify yes or no: "
            else
                break
            endif
        end
        if ($ans =~ [Nn][Oo]) unset mod_mfile
    endif
    if ($?mod_mfile) then
        if (-e $MAGIC && ! -e $MAGIC.pre_alias) cp $MAGIC $MAGIC.pre_alias
        set mod_files = ($mod_files $MAGIC)
        echo ""
        echo "Modifying $MAGIC to allow the file command to identify Alias format files."
        ex - $MAGIC << EOF
        ${DLR}a
#
# Alias format files:
#
8	short		0x18		alias  pix  file
>0	short		x		(%4d *
>2	short		x		%4d)
>4	short		x		offset (%4d,
>6	short		x		%4d)
8	short		0x8		alias mask file
>0	short		x		(%4d *
>2	short		x		%4d)
>4	short		x		offset (%4d,
>6	short		x		%4d)
.
        w! $MAGIC
        q
EOF
    endif
endif

#    In order to support distributed rendering with the Alias software, a
#    render control directory must be created. This directory must be world
#    writable in order to allow any Alias user to write to the directory.
#
#    By default, the render control area will be /usr/aw/alias/render_control,
#    but customers do have the option of creating a shared area at a later
#    time.

set rcdir = $symlink_to_alias/$RCDIR
chkconfig nfs
if ($status == 0) then

#    If the machine has NFS enabled, inform the installer that they may wish
#    to setup a common render control area which is equally accessible from
#    all machines which have NFS enabled. The details for this are in the
#    Alias documentation.

    echo ""
    echo ""
    echo "In order to support distributed rendering with the $vers software, a"
    echo "render control area must be created. This directory must be world writable in"
    echo "order to allow all users equal access to the render control area."
    echo ""
    echo "By default, the render control area will be $symlink_to_alias/$RCDIR."
    echo ""
    echo "Since you have the network file system (NFS) option enabled on your machine,"
    echo "you may be interested in setting up a common render control area which can be"
    echo "shared by other machines running NFS which have the Alias software installed."
    echo ""
    echo "For details on setting up a common render control area, consult the"
    echo "Installation and Release Notes and the V8.0 Addendum for more information"
    echo "on Distributed Render Control."
endif

echo ""
if ($?clienti) then
    echo "If you are planning to perform any distributed rendering, make sure that"
    echo "$rcdir exists on the server and is world writable."
else

#    If this is a server mode install, verify that the render control area
#    exists and its permissions are correct (equally accessible for everyone).

    if (! -d $rcdir) then
        echo "Creating render control area ..."
        mkdir -m 777 -p $rcdir
        if ($status != 0) then
            echo ""
            echo "An error occurred when creating the render control area:"
            echo ""
            echo "    $rcdir"
        endif
    else
        echo "The render control area ($rcdir) already exists."
        echo "Making it world readable, writable and examinable."
        chmod 777 $rcdir
    endif
endif

if ($?render_sftw) then
    goto cleanup
endif

#    Conditionally enable virtual swap:
#
#    If the machine is running an acceptable version of the operating system
#    (already verified) and the vswap chkconfig option (enable or disable
#    virtual swap) is off, conditionally enable it.
#
#    If InstallAlias is running in guru mode, ask the installer if they wish
#    to enable virtual swap. If they say `yes' or InstallAlias is not running
#    in guru mode, enable virtual swap.

chkconfig vswap
if ($status != 0) then
    set en_vs
    if ($?guru_mode) then
        echo ""
        echo "Currently, virtual swap is disabled on this machine. Virtual swap space is"
        echo "used extensively by the $vers software when writing data files and"
        echo "performing renders. It should be enabled or the $vers software may"
        echo "not function correctly."
        echo ""
        echo -n "Do you wish to enable virtual swap on this machine? (yes/no): "
        while (1)
            set ans = $<
            if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
                echo -n "Please specify yes or no: "
            else
                break
            endif
        end
        if ($ans =~ [Nn][Oo]) unset en_vs
    endif
    if ($?en_vs) then
        echo ""
        echo "Enabling virtual swap ..."
        chkconfig vswap on
    endif
endif

#    Conditionally optimize the size of virtual swap:
#
#    If the vswap chkconfig option (virtual swap) is on, conditionally execute
#    the IncreaseVSwap script (/usr/aw/alias/bin/IncreaseVSwap) to verify that
#    the size of virtual swap on this machine is large enough to support the
#    Alias software. If InstallAlias is running in guru mode, explain the
#    situation and ask the installer if they wish to customize the size of
#    virtual swap space. If they say `yes' or InstallAlias is not running in
#    guru mode, customize the size of virtual swap space.
#
#    Note that the script is called with the ``-i'' command flag which tells
#    the script not to prompt for user input after customizing the size of
#    virtual swap.

chkconfig vswap
if ($status == 0) then
    set cust_vs
    if ($?guru_mode) then
        echo ""
        echo ""
        echo "In order for the $vers software to spawn child processes (i.e:"
        echo "raytracer, renderer), and save large files, the size of virtual swap space"
        echo "should be customized to the sum of the size of physical memory and all"
        echo "physical swap spaces. If this is not done, you may experience problems"
        echo "with the software."
        echo ""
        echo "As long as the size of virtual swap space is less than the optimal value,"
        echo "the $vers software will prompt you with a warning message every"
        echo "time it is executed."
        echo ""
        echo "If you are unfamiliar with the idea of virtual swap space, consult the"
        echo "swap manual page."
        echo ""
        echo -n "Do you wish to customize the size of virtual swap space? (yes/no): "
        while (1)
            set ans = $<
            if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
                echo -n "Please specify yes or no: "
            else
                break
            endif
        end
        echo ""
        if ($ans =~ [Nn][Oo]) then
            unset cust_vs
            echo ""
            echo "The size of virtual swap space will not be customized."
            echo ""
            echo "If you wish to perform the customization at a later time, it"
            echo "may be done by executing $symlink_to_alias/bin/IncreaseVSwap."
        endif
    endif

    if ($?cust_vs) then
        echo ""
        echo "Customizing the size of virtual swap space ..."
        $sftwdir/bin/IncreaseVSwap -i
    endif
endif

#    Customize Destkop software:
#
#    The following files are necessary for the customization of the IndigoMagic
#    software so that it recognizes Alias based files and other Alias|Wavefront
#    utilties:
#
#        /usr/lib/filetype/install/AWEvalView.ftr
#        /usr/lib/filetype/install/Alias3D.ftr
#        /usr/lib/filetype/install/iconlib/AWevalview.closed.fti
#        /usr/lib/filetype/install/iconlib/AWevalview.open.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.MS3.closed.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.MS3.open.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.RRFR.closed.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.RRFR.open.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.SoundSync.closed.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.SoundSync.open.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.anim.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.environment.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.flipbook.closed.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.flipbook.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.flipbook.open.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.light.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.mask.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.oldlight.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.oldsdl.closed.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.oldsdl.open.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.oldwire.closed.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.oldwire.open.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.oldwire.top.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.pix.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.qmexec.bottom.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.qmexec.closed.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.qmexec.open.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.qmfile.bottom.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.qmfile.closed.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.qmfile.open.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.qpexec.bottom.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.qpfile.bottom.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.rrfr.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.sdl.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.shader.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.sset.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.texture.fti
#        /usr/lib/filetype/install/iconlib/Alias3D.wire.fti
#        /usr/lib/filetype/install/iconlib/Alias3D_V7.exec.closed.fti
#        /usr/lib/filetype/install/iconlib/Alias3D_V7.exec.open.fti
#        /usr/lib/filetype/install/iconlib/Alias3D_preV7.exec.bottom.fti
#        /usr/lib/filetype/install/iconlib/Alias3D_preV7.exec.closed.fti
#        /usr/lib/filetype/install/iconlib/Alias3D_preV7.exec.open.fti
#        /usr/lib/filetype/install/iconlib/AliasSPV3.canvas.fti
#        /usr/lib/filetype/install/iconlib/AliasSP_PreV3.canvas.closed.fti
#        /usr/lib/filetype/install/iconlib/AliasSP_PreV3.canvas.open.fti
#
#    They appear in the support system files area of the ALIAS software
#    CD-ROM and define a number of file type rules used by the Indigo
#    Magic software to identify and interact with Alias based files.
#
#    These files are always installed if InstallAlias is running in automatic
#    mode. If InstallAlias is running in guru mode the desktop chkconfig
#    option is turned off, ask the installer if they wish to customize the
#    desktop.

echo ""
echo ""
echo "The next step of Install involves the customization of the IRIX IndigoMagic"
echo "software to recognize $vers based files and other Alias|Wavefront"
echo "utilities. This requires the installation of the following files:"
echo ""
echo "    /usr/lib/filetype/install/Alias3D.ftr"
echo "    /usr/lib/filetype/install/AWEvalView.ftr"
echo ""
echo "and a number of file type icon (fti) files used by the named files."
echo ""
echo "The first file (Alias3D.ftr) contains a number of file type rules used by"
echo "the IndigoMagic software to identify $vers based files (i.e.: the"
echo "main Alias executable and associated files). The second file (AWEvalView.ftr)"
echo "contains file type rules which identify the evalview executable."
echo ""
echo "Once a file type has been determined using the file type rules, the fti"
echo "files depict the look of that file on the IndigoMagic desktop."

set cust_imagic
if ($?guru_mode) then
    chkconfig desktop
    if ($status != 0) then
        echo ""
        echo "The desktop behavior of IndigoMagic has been disabled by turning the desktop"
        echo "chkconfig option off (chkconfig desktop off). This disables icon placement"
        echo "on the graphical screen. As long as this option is disabled, you have no need"
        echo "to customize the IndigoMagic software to recognize Alias format files. However,"
        echo "there may be a time in the future where this file recognition is desired."
        echo ""
        echo "Do you wish to customize the IndigoMagic software to recognize $vers"
        echo -n "based files? (yes/no): "
        while (1)
            set ans = $<
            if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
                echo -n "Please specify yes or no: "
            else
                break
            endif
        end
        if ($ans =~ [nN][oO]) then
            echo ""
            echo "The IRIX IndigoMagic software will not be customized to recognize"
            echo "$vers based files."
            unset cust_imagic
        endif
    endif
endif

if ($?cust_imagic) then
    while (1)
        echo ""
        echo "Extracting and installing the Alias IndigoMagic file type rules files"
        echo "and associated file type icon files."
        echo ""

#    Change directories to /usr/lib/filetype/install and "copy" the file type
#    rules files and fti files from the distribution CD-ROM (via tar) into the
#    directory.

        chdir /usr/lib/filetype/install
        (chdir $ALIAS_CDPATH/$ALSYSFILES;tar cf - Alias3D.ftr AWEvalView.ftr iconlib) | tar xvof -
        if ($status == 0) then
            set view_inst
            break
        endif

        echo ""
        echo "It appears that there was a problem in reading the $almedia. You may have to"
        echo "attempt it 2 or 3 times before you're finally successful."
        echo ""
        echo -n "Do you wish to try reading the $almedia again? (yes/no): "

        while (1)
            set ans = $<
            if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
                echo -n "Please specify yes or no: "
            else
                break
            endif
        end
        if ($ans =~ [nN][oO]) break
    end
endif

#    If the files were successfully installed, customize the IndigoMagic
#    software.

if ($?view_inst) then
    echo ""
    echo "Customizing IndigoMagic software to recognize Alias based files ... This"
    echo "will take a few minutes."

#    Remove any Alias Studio based ftr files from /usr/lib/filetype/local.
#    The Alias Studio ftr file has been moved to /usr/lib/filetype/install.

    if (-d /usr/lib/filetype/local) then
        chdir /usr/lib/filetype/local
        foreach f (Alias.ftr Alias3D.ftr)
            if (! -f $f) continue
            rm -f $f
        end
    endif

    chdir /usr/lib/filetype

#    Run make unconditionally to compile the ftr files in /usr/lib/filetype.

    make -u >& /dev/null

    echo ""
    echo "You will have to logout and login again before the desktop icons become"
    echo "visible."
    echo ""
endif

#    There are several icon files, some for 4Dwm and one for mwm (Motif Window
#    Manager):
#
#        /usr/lib/images/Alias.icon
#        /usr/lib/images/DataBrowser.icon
#        /usr/lib/images/EvalView.icon
#        /usr/lib/images/FlipBook.icon
#        /usr/lib/images/RRFR.icon
#        /usr/lib/images/livewire.icon
#        /usr/lib/images/soundsync.icon
#        /usr/include/X11/bitmaps/alias_icon
#
#    Install the files.
#

echo ""
echo ""
echo "Along with the $vers software, the distribution $almedia contains"
echo "several icon files:"
echo ""
echo "    /usr/lib/images/Alias.icon"
echo "    /usr/lib/images/DataBrowser.icon"
echo "    /usr/lib/images/EvalView.icon"
echo "    /usr/lib/images/FlipBook.icon"
echo "    /usr/lib/images/RRFR.icon"
echo "    /usr/lib/images/livewire.icon"
echo "    /usr/lib/images/soundsync.icon"
echo "    /usr/include/X11/bitmaps/alias_icon"
echo ""
echo "Each file is used by an X window manager to indicate a minimized Alias"
echo "executable. The first seven files are used by the 4Dwm window manager and"
echo "the other by the Motif window manager (mwm)."

#    Remove an old Alias.icon file as it might be read-only

set oicon = /usr/lib/images/Alias.icon
if (-f $oicon) then
    chmod u+w $oicon
    rm -f $oicon
endif

while (1)
    echo ""
    echo "Extracting and installing the icon files."
    echo ""

#    Install the icon files.

    chdir /usr/lib
    (chdir $ALIAS_CDPATH/$ALSYSFILES;tar cf - images alias_icon) | tar xvof -
    if ($status == 0) then
        mv -f alias_icon /usr/include/X11/bitmaps
        break
    endif

    echo ""
    echo "It appears that there was a problem in reading the $almedia. You may have to"
    echo "attempt it 2 or 3 times before you're finally successful."
    echo ""
    echo -n "Do you wish to try reading the $almedia again? (yes/no): "

    while (1)
        set ans = $<
        if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
            echo -n "Please specify yes or no: "
        else
            break
        endif
    end
    if ($ans =~ [nN][oO]) break
end

#    Inform the installer that they should install the Alias tablet drivers if
#    they are planning to use tablets with the Alias software. If the Alias
#    software is being installed from CD-ROM, inform the installer that they
#    may install tablet support via the master install script (Install) at the
#    top level of the CD-ROM.

echo ""
echo ""
echo "If you wish to use tablets with the $vers software, your machine"
echo "must be customized to recognize the tablets."
echo ""
echo "The tablet drivers may be installed using the Install script at the top"
echo "level of the CD-ROM ($ALIAS_CDPATH/Install)."
echo ""
echo -n "For details on the installation of tablets, see the"
echo ' "Tablet Installation Notes"'
echo "in the Release Notes."
echo ""

cleanup:

#    Check if any of the saved system files have been changed. If a file has not
#    been changed, remove the ".pre_alias" file; else rename the ".pre_alias"
#    file to a file ending with '=' and report the renaming [ i.e.: mv
#    /etc/passwd.pre_alias /etc/passwd= ].    

echo ""
foreach fname ($mod_files)
    if (-e $fname.pre_alias) then
        cmp -s $fname $fname.pre_alias
        if ($status == 0) then
            rm -f $fname.pre_alias
        else
            mv $fname.pre_alias ${fname}=
            echo "The original version of $fname has been renamed to ${fname:t}=."
        endif
    endif
end

#    Install the correct version of the Silicon Graphics license_eoe software
#    on the machine. There are three versions of the software, one for IRIX 5.3
#    machines, one for IRIX 6.2 and the other for IRIX 6.3 machines.
#
#    Security within Alias|Wavefront products is using the FlexLM software
#    packaged within the license_eoe inst image. So, in preparation for the
#    use of the licensing software, Install installs the license_eoe software.
#
#    This software must be installed in all cases as it applies to all
#    Alias|Wavefront software.
#
#    The books and man subsystems of the license_eoe software are not installed
#    in case they are mounted on NFS or other read only filesystems.
#
#    If inst exits with a non-zero status, ask the installer if they wish
#    to attempt the installation of the licensing software again. If they
#    say `no', exit the installation gracfully, otherwise, try installing
#    the licensing software again.

if ($?do_liceoe) then
    if ($os == 5.3) then
        set lic = $ALIAS_CDPATH/$INSTDIR/license_eoe.i53
    else if ($os == 6.2) then
        set lic = $ALIAS_CDPATH/$INSTDIR/license_eoe.i62
    else if ($os == 6.3) then
        set lic = $ALIAS_CDPATH/$INSTDIR/license_eoe.i63
    endif

    echo ""
    echo ""
    echo "This release of Alias|Wavefront software is using Silicon Graphics licensing"
    echo "tools for product licensing. The licensing software must be installed on this"
    echo "machine in order for the product licensing mechanism to be successful."
    if ($?lic) then
        while (1)
            echo ""
            echo ""
            echo "Installing licensing software ..."
            echo ""
            if ($os == 5.3) then
                inst -f $lic -a -K license_eoe.books,license_eoe.man -I license_eoe.sw
                set exstatus = $status
            else
                inst -f $lic -F $ALIAS_CDPATH/$INSTDIR/.data/license_eoe.inst -a | tee $IOUT
                set exstatus = $status
            endif

#    After the attempted installation of the license_eoe software, check for
#    the string:
#
#    ERROR: Automatic installation failed: Nothing selected for installation.
#
#    in the (tee'ed) output of the inst command. If that string is detected
#    in the file, it means that (pieces of) the same (or newer) license_eoe
#    software are already installed (thus causing the error). Inform the
#    installer.
#
#    Since inst generated an error with this condition, the exit status will
#    be non-zero. Because we know the cause of this specific error (an
#    acceptable version of the licensing software is already installed), we
#    can (re)set the exit status of the inst process to zero.

            if (-f $IOUT) then
                set estr = "ERROR: Automatic installation failed: Nothing selected for installation."
                grep -s "^${estr}${DLR}" $IOUT >& /dev/null
                if ($status == 0) then
                    echo ""
                    echo ""
                    echo "The following string, as output by Install:"
                    echo ""
                    echo "  $estr"
                    echo ""
                    echo "indicates that the correct (or newer version) of the licensing software is"
                    echo "already installed on this machine."
                    echo ""
                    echo "Continuing with the installation ..."
                    echo ""
                    set exstatus = 0
                endif
                rm -f $IOUT
            endif

            if ($exstatus == 0) break

            echo ""
            echo ""
            echo ""
            echo "It appears that there was a problem in installing the licensing software."
            echo "You may have to attempt it 2 or 3 times before you're finally successful."
            echo ""
            echo -n "Do you wish to try installing the licensing software again? (yes/no): "
    
            while (1)
                set ans = $<
                if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
                    echo -n "Please specify yes or no: "
                else
                    break
                endif
            end
            if ($ans =~ [nN][oO]) goto userexit
        end
    else
        echo ""
        echo "Cannot install licensing software due to an unsupported operating system ($os)."
    endif
endif

#    Install/update the Alias|Wavefront common software in /usr/aw/COM. An
#    important piece of this software is the Licenser. It provides a unique
#    licensing system used by all Alias|Wavefront products. The installation
#    of the common software can be done in one of two ways, depending on the
#    mode of the installation (client or server).
#
#    When this process is done, one of two setups has to exist:
#
#        /usr/aw/COM -> COM2.0 (a directory)
#        /usr/aw/COM -> COM2.0 -> /nfs/<remote machine>/usr/aw/COM2.0
#
#    in order for the Licenser and Alias software to work correctly.

echo ""
echo ""
echo "An important, but separate piece of the Alias|Wavefront software is the"
echo "common software. It contains a few executables and several system libraries"
echo "which are shared by one (or more) pieces of Alias|Wavefront software."
echo ""
echo "An important piece of this software is the Licenser. It provides a unique"
echo "licensing system used by all Alias|Wavefront products."

#    If /usr/aw/COM2.0 already exists, it indicates that a previous version
#    of the common software has been installed on this machine. If the
#    software was installed as part of a client mode Alias install,
#    /usr/aw/COM2.0 may be symbolic link to the common software on an
#    NFS server.
#
#    In both cases, we want to merge the new common software with the
#    existing common software. If the common software is installed on
#    this machine (/usr/aw/COM2.0 is a directory), we can install the
#    new common software here. If the common software is not installed
#    on this machine (/usr/aw/COM2.0 is a symbolic link), we can't
#    install the common software and insist that it be installed on
#    the NFS server which the /usr/aw/COM2.0 link accesses.
#
#    If the symbolic link method is used, verify that the target of the
#    link exists (directory [-d] test succeeds). If the target of the
#    symbolic link does not exist, inform the installer and remove the
#    dangling symbolic link (/usr/aw/COM2.0).

set inst_ok
if (-d $awlocn/$COM2) then
    set comexists
    echo ""
    echo "The common software already appears to be installed on this machine. This"
    echo "indicates the installation of an earlier version of an Alias|Wavefront"
    echo "product."
    echo ""
    echo "In order to support both the new Alias software and any previously installed"
    echo "Alias|Wavefront products, the common software distributed with this release"
    echo "should be merged with the existing common software."
    echo ""
    if (-l $awlocn/$COM2) then

#    Check to see if the common software is local (installed on) to this
#    machine:
#
#    Determine the true location of the common software (target of the
#    /usr/aw/COM2.0 symbolic link). Run a find command using that pathname
#    checking for any local (i.e.: not NFS mounted) files or directories
#    (i.e.: `find dir -local -print' should at least print the value of `dir'
#    if it is local to the machine). If the find command command does not print
#    any pathnames, the common software is not installed on this machine. In
#    this case, we want the installer to install the new common software on the
#    NFS server which contains the existing common software.
#
#    If the find command does print some pathnames, we assume that the common
#    software is installed on this machine and prepare to update the common
#    software.
#
#    The find command depends on the fact that the target of /usr/aw/COM2.0
#    exists (If the  target file/directory did not exist, the directory test
#    above would fail). If the target of the symbolic link does not exist,
#    the find command will not print any pathnames, therefore implying that
#    the common software is not local to this machine.

        set FOUT = $TMPDIR/fout.$$
        set ctarg = `ls -l $awlocn/$COM2 | awk '{print $11}'`
        (find $ctarg -local -print > $FOUT) >& /dev/null
        if (-z $FOUT) then
            echo ""
            echo "It appears that the common software is not installed on this machine. It is"
            echo "installed on the server indicated by the following pathname:"
            echo ""
            ls -l $awlocn/$COM2 | awk '{printf "    %s\n", $11}'
            echo ""
            echo "Unless you have already done so, the new common software must be installed"
            echo "on the indicated machine before using the new Alias software."
            echo ""
            echo "If the new common software is not installed correctly, the new Alias software"
            echo "will not perform correctly."
            unset inst_ok
        endif
        rm -f $FOUT
    endif
else if (-e $awlocn/$COM2 || -l $awlocn/$COM2) then

#    If /usr/aw/COM2.0 exists, but is not a directory (i.e.: a dangling
#    symbolic link or a file), clean up the mess and continue with the
#    installation.

    echo ""
    if (-l $awlocn/$COM2) then
        echo "It appears that the common software has already been setup on this machine,"
        echo -n 'but the symbolic link which references it '
        echo "($awlocn/$COM2) does not appear"
        echo "to be correct:"
        echo ""
        ls -l $awlocn/$COM2 | awk '{printf "    %s -> %s\n", $9, $11}'
        echo ""
        echo "Removing dangling symbolic link ..."
    else
        echo "The planned location of the common software ($awlocn/$COM2) is a file, not"
        echo "a directory as it's supposed to be. It must be removed to allow the installation"
        echo "of the common software."
        echo ""
        echo "Removing the $awlocn/$COM2 file ..."
    endif
    rm -f $awlocn/$COM2
endif

#   If the installation of the common software is still a go (inst_ok flag
#   is still set), continue.

if ($?inst_ok && ! $?comexists) then

#    If the common software is not installed on this machine, attempt to
#    install it.
#
#    If the installation is being performed in client mode, the installer
#    has the option of installing a local copy of the common software on
#    the local machine or creating a symbolic link to an existing /usr/aw
#    structure on a server which has the common software installed.
#
#    If the installation is being performed in server mode, the common
#    software will be installed in /usr/aw/COM2.0.

    if ($?clienti) then
        echo ""
        echo "If you used Install to install the $vers software, the common"
        echo "software should have been installed on the server as well."
        echo ""
        echo "The common software must be made available to this machine before the"
        echo "$vers software can be used. You can either install a copy of"
        echo "the common software on this machine or create a symbolic link between"
        echo "the common software on the server and $awlocn on this machine."
        echo ""
        echo -n "Do you wish to install the common software on this machine? (yes/no): "
        while (1)
            set ans = $<
            if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
                echo -n "Please specify yes or no: "
             else
                break
             endif
        end
        if ($ans =~ [Nn][Oo]) then
            unset inst_ok
            echo ""
            echo "Since you chose not to install the common software on this machine, the"
            echo "install procedure requires that you provide the complete pathname to a"
            echo "previously installed instance of the common software. The specified"
            echo "pathname must end with $COM2."

            while (1)
                echo ""
                echo "What is the complete pathname to a previously installed instance of the"
                echo -n "common software?: "
                set pname = $<
                set awcomlocn = ($pname)

#    Verify that the installer typed something meaningful.

                if ($#awcomlocn != 1) continue

#    Verify that the supplied pathname ends with COM2.0.

                set csuff = $awcomlocn:t
                if ("$csuff" != $COM2) then
                    echo ""
                    echo "Please specify a pathname that ends with $COM2."
                    continue
                endif

#        Verify that the specified location exists and is a directory.
#
#        If it is a directory, create a symbolic link between the specified
#        pathname and /usr/aw/COM2.0.

                if (-e $awcomlocn) then
                    echo ""
                    echo "Checking the pathname for the common software ..."
                    if (-d $awcomlocn) then
                        echo ""
                        echo "Creating a symbolic link to the common area on the specified server:"
                        echo ""
                        echo "    $awlocn/$COM2 -> $awcomlocn"
                        echo ""
                        ln -s $awcomlocn $awlocn/$COM2

#    Make sure /usr/aw/COM is a symbolic link to COM2.0:
#
#    If /usr/aw/COM exists, remove it and create the symbolic link.

                        set rcom = $awlocn/COM
                        echo "In order to correctly install the common software, $rcom must be a"
                        echo "a symbolic link to the common software in $awlocn/$COM2."
                        if (-l $rcom || -e $rcom) then
                            echo ""
                            echo "Removing $rcom ..."
                            rm -fr $rcom
                        endif
                        echo ""
                        echo "Creating symbolic link ($awlocn/COM -> $COM2) ..."
                        ln -s $COM2 $rcom
                        break
                    else
                        echo ""
                        echo "While the pathname to $awlocn on the server:"
                        echo ""
                        echo "    $awcomlocn"
                        echo ""
                        echo "exists, it is not a directory:"
                        echo ""
                        ls -dl $awcomlocn | awk '{printf "    %s     %s\n", $1, $NF}'
                        echo ""
                        echo "At this point, you have the option of installing the common software on"
                        echo "this machine or specifying a different location for an installed instance"
                        echo "of the common software."
                        echo ""
                        echo -n "Do you wish to install the common software on this machine? (yes/no): "
                        while (1)
                            set ans = $<
                            if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
                                echo -n "Please specify yes or no: "
                            else
                                break
                            endif
                        end
                        if ($ans =~ [Yy][Ee][Ss]) then
                            break
                        else
                            unset inst_ok
                            echo ""
                            echo "Please specify an alternate pathname."
                        endif
                    endif
                else
                    echo ""
                    echo "It appears that $awcomlocn does not exist."
                    echo ""
                    echo "Please try again."
                endif
            end
        endif
    endif
endif

#    If the Alias software was installed in server mode or the guru
#    installer wishes to install a local copy of the common software,
#    install the common software using inst.

if ($?inst_ok) then
    echo ""
    if ($?comexists) then
        echo "Merging the common software into $awlocn/COM ..."
    else

#    If the common software has not been installed on this machine and the
#    installer wishes to install it, attempt to do so.

        echo ""
        echo "Searching for a host filesystem for the common software ..."

#    From above, we have an array of writable local filesystems (wlocal_fsys)
#    which we can use to determine candidate locations for the common software.
#
#    Walk through the list of filesystems and find those that have enough
#    free disk space for the common software.

        set cfs = ()
        set cfsds = ()
        foreach cfsys ($wlocal_fsys)
            if ("$cfsys" == "/usr") then
                set usrfs
            endif
            set fds = `df -k $cfsys | sed "1d" | awk '{print $5}'`

#    Convert kbytes to Mbytes

            @ fds /= 1024
            if ($fds > $comspace) then
                set cfs = ($cfs $cfsys)
                set cfsds = ($cfsds $fds)
            endif
        end

#    If there are no local filesystems with sufficient free disk space for
#    the common software inform the installer.
#
#    If there is one filesystem with sufficient free disk space, the common
#    software will be installed there, but where? If it is the root filesystem
#    (/), we would like to install the common software in /usr/aw/COM2. However,
#    if /usr is a local filesystem, we can't install it there. In this case,
#    install the common software in /aw/COM2.0. This is a rare case. In all
#    other single filesystem problems, install the common software in
#    /<filesystem>/aw/COM2.0.
#
#    If ther is more than one filesystem with sufficient free disk space, ask
#    the installer on which filesystem they wish to install the software. If
#    they pick the root filesystem, we have to do the same checking for a
#    /usr filesystem as the last case. If they pick any other local filesystem,
#    install the common software in /<filesystem>/aw/COM2.0.

        echo ""
        if ($#cfs == 0) then
            unset inst_ok
            echo "There is insufficient disk space for the common software on your machine."
            echo "You should free up the required disk space ($comspace megabytes) on a filesystem"
            echo "local to your machine and attempt to install the common software by choosing"
            echo '"Supplementary Alias|Wavefront products" from the install menu.'
            echo ""
        else if ($#cfs == 1) then
            set cofs = $cfs
            echo "The only filesystem with sufficient free disk space for the common software"
            echo "is $cofs."
        else
            while (1)
                echo "The following filesystems have sufficient free disk space for the common"
                echo "software:"
                echo ""
                @ i = 1
                while ($i <= $#cfs)
                    echo "    $cfs[$i] ($cfsds[$i] megabytes free)"
                    @ i++
                end
                echo ""
                while (1)
                    echo "Please specify which filesystem you wish to install the common"
                    echo -n "software on: "
                    set pname = $<
                    set cofs = ($pname)
                    if ($#cofs == 1) break
                end
                @ index = 1
                @ found = 0
                while ($index <= $#cfs && $found == 0)
                    if ("$cfs[$index]" == "$cofs") then
                        @ found++
                    else
                        @ index++
                    endif
                end
                if ($found != 0) break

                echo ""
                echo "$cofs is not a valid choice. Please choose one of:"
                echo ""
            end
        endif
        if ($?inst_ok) then
            set cdname = $awlocn:t
            if ("$cofs" == "/") then
                if ($?usrfs) then
                    set comlocn = /$cdname/$COM2
                else
                    set comlocn = $awlocn/$COM2
                endif
            else
                set comlocn = $cofs/$cdname/$COM2
            endif

            echo ""
            echo "Installing the common software in $comlocn ..."

#    Now that we know where the common software will be installed, if it's
#    anything other than /usr/aw/COM2.0, create a symbolic link between
#    that location and /usr/aw/COM2.0.

            if ($comlocn != $awlocn/$COM2) then
               mkdir -p $comlocn
               ln -s $comlocn $awlocn/$COM2
            endif
        endif
    endif
    if ($?inst_ok) then

#    If we are installing the Alias render software, we need only install
#    the awcommon inst image (contains the Licenser), a small subset of the
#    full common software loaded for the other Alias products.
#
#    If we are installing any software other than render software, install
#    those (common) pieces of software which the Alias software requires to
#    exist in /usr/aw/COM2.0.
#
#    If inst exits with a non-zero status that we can't handle, ask the
#    installer if they wish to attempt the installation of the common
#    software again. If they say `no', exit the installation gracfully,
#    otherwise, try installing the common software again.

        echo ""
        while (1)
            if ($?render_sftw) then
                if ($os == "5.3") then
                    inst -f $ALIAS_CDPATH/$INSTDIR/required -a -I awcommon
                    set exstatus = $status
                else
                    inst -f $ALIAS_CDPATH/$INSTDIR/required/awcommon -a | tee $IOUT
                    set exstatus = $status
                endif
            else
                if ($os == "5.3") then
                    inst -f $ALIAS_CDPATH/$INSTDIR/required -a -K awxfiles.doc,explore4_3_1.3d -I alias8_0,awcommon,awxfiles,explore4_3_1.common
                    set exstatus = $status
                else

#    Note that IRIX 6.3 doesn't like comma separated selections following a
#    -I flag (i.e. -I a,b,c). They need to specified separately (i.e.:
#    -I a -I b -I c). Luckily, we don't need to do this here.

                    inst -f $ALIAS_CDPATH/$INSTDIR/required -a | tee $IOUT
                    set exstatus = $status
                endif
            endif

#    After the attempted installation of the common software, check for the
#    string:
#
#    ERROR: Automatic installation failed: Nothing selected for installation.
#
#    in the (tee'ed) output of the inst command. If that string is detected
#    in the file, it means that (pieces of) the same (or newer) common software
#    are already installed (thus causing the error). Inform the installer.
#
#    Since inst generated an error with this condition, the exit status will
#    be non-zero. Because we know the cause of this specific error (the
#    common software is already installed), we can (re)set the exit status
#    of the inst process to zero.

            if (-f $IOUT) then
                set estr = "ERROR: Automatic installation failed: Nothing selected for installation."
                grep -s "^${estr}${DLR}" $IOUT >& /dev/null
                if ($status == 0) then
                    echo ""
                    echo ""
                    echo "The following string, as output by Install:"
                    echo ""
                    echo "  $estr"
                    echo ""
                    echo "indicates that the correct (or newer) version of the common software is"
                    echo "already installed on this machine."
                    echo ""
                    echo "Continuing with the installation ..."
                    echo ""
                    set exstatus = 0
                endif
                rm -f $IOUT
            endif

            if ($exstatus == 0) break

            echo ""
            echo ""
            echo ""
            echo "It appears that there was a problem in installing the common software."
            echo "You may have to attempt it 2 or 3 times before you're finally successful."
            echo ""
            echo -n "Do you wish to try installing the common software again? (yes/no): "
    
            while (1)
                set ans = $<
                if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
                    echo -n "Please specify yes or no: "
                else
                    break
                endif
            end
            if ($ans =~ [nN][oO]) goto userexit
        end
    endif
endif

set CLIB = $awlocn/$COM2/lib
if (-f $CLIB/WaveLic.so && -f $CLIB/getid.so) then

#    Immediately after the common software is installed, verify that the
#    prequisite DSOs exist, then execute findkey to (hopefully) prekey the
#    software. The environment variable AW_PRE_KEY must be set to the
#    directory containing the pre-key file.

    setenv AW_PRE_KEY $ALIAS_CDPATH/Products/InstBased/.data/prereg/FLEX
    $ALIAS_CDPATH/$FKEY -l
endif

#    Now that the non-render Alias software has been installed, a few more
#    things need to be done:
#
#    - If the software was installed in server mode, some links between the
#      common software and the Alias software must be setup.

if (! $?render_sftw) then

#    If the Alias software was installed in server mode, do a little more work
#    in /usr/aw/alias connected with the installation/setup of the common
#    software.

    if (! $?clienti) then

#    Create symbolic link from /usr/aw/alias/bin/awxfiles to
#    /usr/aw/COM2.0/bin/awxfiles. If /usr/aw/alias/bin/awxfiles already
#    exists, remove it. This step is not performed if the Render software
#    is being installed.

        set AAWX = $sftwdir/bin/awxfiles
        if (-e $AAWX || -l $AAWX) then 
            rm -fr $AAWX
        endif 

        set CAWX = $awlocn/$COM2/bin/awxfiles
        if (-f $CAWX) then
            ln -s $CAWX $AAWX
        else
            echo ""
            echo "Cannot find $CAWX:t in $CAWX:h."
        endif

#    If anything other than Alias Render software is being installed, setup
#    those libraries required by the Alias software:
#
#    Parts of the Alias software require the OpenModel and other libraries
#    to execute. They are located in /usr/aw/COM2.0/lib and have a suffix
#    of ".4" to identify their version. Instead of copying the libraries to
#    the Alias lib directory (/usr/aw/alias/lib), we create symbolic links
#    from the Alias lib directory to the lib directory in /usr/aw/COM2.0. We
#    also drop the ".4" suffix in naming the symbolic links so that ODS
#    (OpenAlias, OpenModel, OpenRender) applications don't notice (or
#    concern themselves) with the new version of the library. For example:
#
#     /usr/aw/alias/lib/libalias_api.so -> /usr/aw/COM2.0/lib/libalias_api.so.4

        set ALIB = $sftwdir/lib
        set CLIB = $awlocn/$COM2/lib

        set reqdlibs = (libalias_api.so libapi_image.so libapi_memory.so libExpTrans.so libExpIO.so)
        foreach lib ($reqdlibs)
            if (! -f $CLIB/$lib.4) then
                echo ""
                echo "Cannot find $lib.4 in $CLIB. Unable to symbolically"
                echo "link $lib to $symlink_to_alias/lib."
            endif
            rm -f $ALIB/$lib $ALIB/$lib.4
            ln -s $CLIB/$lib.4 $ALIB/$lib
        end

        set reqdlibs = (libExpModel.so libAliasExpGeo.so)
        foreach lib ($reqdlibs)
            if (! -f $CLIB/$lib.3) then
                echo ""
                echo "Cannot find $lib.3 in $CLIB. Unable to symbolically"
                echo "link $lib to $symlink_to_alias/lib."
            endif
            rm -f $ALIB/$lib $ALIB/$lib.3
            ln -s $CLIB/$lib.3 $ALIB/$lib
        end
        echo ""
    endif
endif

#    Ask the installer if they wish to setup a demo account to use/demo
#    the Alias software.
#
#    If they say `yes', call setupacct to create/update an account.

echo ""
echo "Do you wish to setup a demo account to run the $vers"
echo -n "software? (yes/no): "
while (1)
    set ans = $<
    if ("$ans" !~ [yY][eE][sS] && "$ans" !~ [nN][oO]) then
        echo -n "Please specify yes or no: "
    else
        break 
    endif
end

if ($ans =~ [Yy][Ee][Ss]) then
    setenv on_cd
    $ALIAS_CDPATH/$ALIAS/bin/setupacct
endif

echo ""
echo ""
echo "The CourseWare files used in the Learning Alias level one tutorials plus many"
echo "sample shaders, textures, models and animations can be found on 3DCD, the"
echo "accompanying CD-ROM."
echo ""
echo "Please consult the release notes and CD-ROM booklet for additional information"
echo "on how to install and use the tutorial files."

cat << EOF


     *************************************************************
     *                                           		 *
     *  Installation of the $vers software is complete	 * 
     *                                           		 *
     *************************************************************


EOF
echo ""
if ($?getenter) then
    echo "Once you have recorded the licensing information displayed above,"
    echo -n "press <ENTER> to continue: "
    set a = $<
endif

echo ""
echo ""
echo -n "Press <ENTER> to return to the main Install procedure: "
set a = $<

#    I think I have to use an exit status of zero here in case InstallAlias
#    is returning from a root sub-shell (`su - root $cmd' above). After the
#    su command is complete, the exit status is examined and if non-zero, will
#    not produce the desired results.

exit 0

baderr:
echo ""
echo "There has been an error in the installation procedure ..."
echo "Please record the error message and contact Alias|Wavefront Assist."
echo "This situation must be corrected before the installation can continue."
echo ""
echo "The error encountered was:"
echo ""
echo $errmsg1
echo $errmsg2
echo ""
echo -n "Press <ENTER> to continue: "
set a = $<
exit

userexit:
echo ""
if ($?vers) then
    echo "Ok. Installation of the $vers software has been aborted. When you"
    echo "are ready to install the software, attempt the installation again."
else
    echo "Ok. Installation has been aborted. When you are ready to install the software,"
    echo "attempt the installation again."
endif
echo ""
echo ""
echo -n "Press <ENTER> to continue: "
set a = $<
exit
