#! /bin/csh -f
#
# install - Script for installing Confluent products from CD-ROM.
#
# Version 1.3
#
# Pre:
#    $1 - "status" => list currently installed products
#
# This script must be executed from a valid distribution directory, such
# as the top-level directory of the CD-ROM.  A valid distribution directory
# contains the admin directory and top-level product directories
# (e.g., util-1.2, vt-1.2).
#
# This script must reside in a directory with other scripts from the
# admin directory.
#
# For example, if the CD-ROM is mounted as /cdrom, the following
# installation procedures are valid and equivalent:
#
#  1. Execute this script via the short install script in the top directory
#     of the CD-ROM:
#       cd /cdrom
#       install
#
#  2. Copy the directory containing this script and execute the copy of
#     this script:
#       cp -r /cdrom/admin /tmp/admin_tmp
#       cd /cdrom
#       /tmp/admin_tmp/install
#
# This routine uses the following utility scripts:
#   abort - abort and exit the top csh script
#   admin_check - check for required files in admin directory
#   conf_init - initialize configuration arrays with product information
#   create_dir - create a directory if it does not exist
#   exit - exit the top csh script
#   file_info - get file information
#   format_line - format strings with specified string formats
#   get_dir - get, create, and check a directory path
#   get_links - get a list of link paths matching a base path
#   get_version - get the version of the admin, doc, and license directories
#   inst_init - initialize for install and uninstall
#   match_arrays - match strings with arrays of strings
#   match_path - match a path with an array of paths using hardpaths
#   modify_docs - set top document path in all documents in directory hierarchy
#   prompt - get the directory and actions in case of failure
#   set_mode - set the permissions mode of files in a path
#
# The following directories are defined:
#   admin_dir:   directory containing scripts executed by install
#   current_dir: current directory when install started
#   tmp_dir:     temporary distribution directory for ISO9660 format
#   dist_dir:    distribution directory (current_dir or tmp_dir)
#   install_dir: installation directory
#   bin_dir:     executable directory containing command links
#   man_dir:     man pages directory containing man page links
#
# The following working arrays are used:
#   installed: 1 => installed
#   map:       indices of products available for installation
#   install:   1 => install
#   cp_share:  1 => install share directory
#
# Copyright (c) 1994 by
#
#    Confluent, Inc.
#    400 Spear St., Suite 207
#    San Francisco, CA 94105
#
# Voice: 415-764-1000
# Fax: 415-764-1008
# Internet: info@confluent.com
#
# Created: 940905 - wpt : For vt-1.0 and util-1.0 on sunos-4.1
# Modified: 941103 - wpt : Change sed script delimiters from , to ;
# Modified: 941227 - jag : Move to admin and rewrite
#                          Change subroutines to sourced csh scripts
# Modified: 950121 - jag : Change mkdir to create_dir, chmod to set_mode
# Modified: 950126 - jag : Fix df output for multiple lines and space > 10GB
# Modified: 950206 - jag : Send product and oshead to get_links
# Modified: 950302 - jag : Check umask for correct access
# Modified: 950309 - jag : Remove use of link_oshead for get_links
# Modified: 950314 - jag : Use match_path to compare file paths
#                          List renamed executable links
#                          Disable interrupts during file install
# Modified: 950422 - jag : Use $system to set du and df commands
#                          Use new get_version to compare directory versions
#                          Remove -f option from chmod
# Modified: 950827 - jag : Create admin link directory and extract archive
#                          for ISO9660-named distribution files (HP-UX)
#                          Move introduction to beginning
# Modified: 950829 - jag : List commands to run products and mention doc
# Modified: 950919 - jag : Fix check for man pages directory in MANPATH
# Modified: 970110 - jag : Quote glob arguments
# Modified: 970219 - jag : Remove use of :q modifier
# Modified: 970503 - jag : Use inst_init/df_bad to warn of no disk space check

# This script should be rewritten to be menu-driven.

#----------------------------------------------------------------------
# Check admin directory
#----------------------------------------------------------------------

#set echo

# Set the admin directory for sourcing csh scripts to the directory
# containing this script.
# It may be relative or absolute and is set to "." if there are no
# leading path components.
set admin_dir = $0
set admin_dir = $admin_dir:h
if ($admin_dir == $0) set admin_dir = "."

# The file names used in the distribution can have the following properties:
#   ISO9660 (8.3) format (e.g., "admin_ch.")
#   upper case (e.g., "ADMIN_CHECK")
#   version number suffix (e.g., "admin_ch.;1")

# The determination of the format used for file names in the distribution
# is based on the form of the install script in the admin directory.
# Since the admin directory can be copied elsewhere and renamed, we cannot
# depend on the name of the admin directory, its parent directory, or other
# files in the parent directory.

# Set up commands to convert file names from their required format to that
# used in the distribution.  The conversion is performed with:
#   set new = `echo $old | tr "$name_case[1]" "$name_case[2]"`
#   set new = `echo $new | sed -e "$name_iso"`$name_ver

# Use a temporary admin link directory with the required file names if the
# file names in the distribution are not as required.
set admin_link = 0

# Save the state of nonomatch and turn it on so glob will return the
# filename substitution pattern if there are no matches.
set nonomatchset = $?nonomatch
set nonomatch

# Determine whether file names are in upper case.
set file = $admin_dir/'INSTALL*'
set temp = `glob "$file"`
if ("$temp" == "$file") then
  set name_case = (" " " ")
else
  set name_case = ("[a-z]" "[A-Z]")
  set admin_link = 1
endif

# Determine whether file names are in ISO9660 format.
set file = $admin_dir/'{install,INSTALL}.*'
set temp = `glob "$file"`
if ("$temp" == "$file") then
  set name_iso = "s/ / /"
else
  set name_iso = 's/^\(.\{1,8\}\).*$/\1./'
  set admin_link = 1
endif

# Determine whether file names have a version number suffix.
set file = $admin_dir/'{install,INSTALL}*;1'
set temp = `glob "$file"`
if ("$temp" == "$file") then
  set name_ver = ""
else
  set name_ver = ";1"
  set admin_link = 1
endif

# Restore the state of nonomatch.
if (! $nonomatchset) unset nonomatch

# If an admin link directory is used, set up to create it, create links
# in it to the admin directory, and remove it in exit.
if ($admin_link) then
  set admin_link_dir = /tmp/confluent_tmp.$$
  set exit_files = $admin_link_dir
endif

# Set up the path for admin_check and the install command.
set file = `echo admin_check | tr "$name_case[1]" "$name_case[2]"`
set file = $admin_dir/`echo $file | sed -e "$name_iso"`$name_ver
set install_cmd = `echo install | tr "$name_case[1]" "$name_case[2]"`
set install_cmd = ./`echo $install_cmd | sed -e "$name_iso"`$name_ver

# Check that the admin directory contains the required files.
# If an admin link directory is used, it will be created.
if (-r $file) then
  source $file
else
  echo ""
  echo "The following file is not available:"
  echo ""
  echo "   $file"
  echo ""
  echo "Aborting."
  exit (0)
endif

# If an admin link directory is used, change the admin directory to
# the admin link directory.  This allows execution of scripts that do
# not require access to distribution files outside the admin directory.
if ($admin_link) then
  set admin_dir = $admin_link_dir
endif

#----------------------------------------------------------------------
# Basic initialization
#----------------------------------------------------------------------

# Set up the interrupt label.
# This should be done after $admin_dir is set and the admin directory is
# checked for required files.
onintr cleanup_mark

# Initialize.
# current_dir will always remain at the original location.
source $admin_dir/inst_init

# Set the default distribution directory to the current directory.
# This will change to the temporary distribution directory if it is used.
set dist_dir = $current_dir

#----------------------------------------------------------------------
# Introduction
#----------------------------------------------------------------------

# Banner and intro.
if ($paging) clear
echo ""
echo "----------------------------------------------------------------------"
echo "Confluent Installer ($install_version_d)"
echo "----------------------------------------------------------------------"
echo ""
echo "This script will install Confluent products from the distribution"
echo "directory (the current directory when this script was started):"
echo ""
echo "   $current_dir"
echo ""
echo "Specifying the optional 'status' argument lists products in the"
echo "current directory that are installed or available for installation."
echo ""
echo "You will be asked a series of questions.  Your system will not"
echo "be changed until this script says it will do so."
echo ""
echo "Default answers to questions will appear in brackets before"
echo "the prompt and will be used if you just press <return>."
echo "Default shell variables, '~', and relative paths are interpreted"
echo "for directory paths."
echo ""
echo "You may type 'exit' at any prompt to exit the installation script."
echo "Please press <return> to continue, anything else to exit."
set udefault = ""
source $admin_dir/prompt
if ("$userin" != "") goto cleanup_mark

#----------------------------------------------------------------------
# Set up distribution in temporary directory
#----------------------------------------------------------------------

# Proceed with initialization if an admin link directory is not used.
if (! $admin_link) goto init_mark

# Construct the archive file name.
set archive = `echo zz.tar | tr "$name_case[1]" "$name_case[2]"`$name_ver

# The archive file must be readable in the current directory.  If not, abort.
if (! -r $archive) then
  echo ""
  echo "A copy of the distribution must be extracted from an archive file"
  echo "before proceeding.  The current directory"
  echo ""
  echo "   $current_dir"
  echo ""
  echo "does not contain a readable copy of the following archive file:"
  echo ""
  echo "   $archive"
  echo ""
  echo "Please change to the top-level distribution directory"
  echo "(e.g., /cdrom, /cdrom/cdrom0) and type:"
  echo ""
  echo "   $install_cmd"
  echo ""
  goto cleanup_mark
endif

# Get the space required for the temporary copy of the distribution.
# This should be close to the size of the archive file.
set temp = (`$du_cmd $archive`)
@ required_space = $temp[1]
if ($du_blocks) @ required_space /= 2

# Set up the default temporary directory.
set tmp_dir_def = /usr/local/confluent_tmp.$$

# Get the temporary directory.
if ($paging) clear
echo ""
echo "----------------------------------------------------------------------"
echo "Temporary Directory"
echo "----------------------------------------------------------------------"

tmp_dir_mark:

# Get the temporary directory.
echo ""
echo "I will need to extract a copy of the distribution from an archive file"
echo "to a temporary directory that will be removed at the end of the"
echo "installation.  The temporary directory must be empty and have at"
echo "least $required_space KB of free disk space available."
echo "The recommended temporary directory is:"
echo ""
echo "   $tmp_dir_def"
echo ""
echo "Is this OK?  If so, press <return>; otherwise, type the temporary"
echo "directory that you wish to use."
set get_dir_def = "$tmp_dir_def"
set get_dir_type = "temporary"
source $admin_dir/get_dir
if ($return_result != 0) goto tmp_dir_mark
set tmp_dir = "$get_dir"

# The temporary directory must be empty.
set temp = (`ls -a $tmp_dir`)
if ($#temp > 2) then
  echo ""
  echo "The specified temporary directory"
  echo ""
  echo "   $tmp_dir"
  echo ""
  echo "is not empty.  The temporary directory must be empty to avoid losing"
  echo "existing files when the directory is removed at the end of the"
  echo "installation.  Please press <return> to re-specify the temporary"
  echo "directory, or type 'exit' and <return> to exit this script."
  set udefault = ""
  source $admin_dir/prompt
  goto tmp_dir_mark
endif

tmp_space_mark:

# Get the available space.
set temp = (`$df_cmd $tmp_dir | sed -e 's/\-\([0-9]\{6\}\)/ 1\1/g'`)
@ i = $#temp - 5
set temp = ($temp[$i-])
set install_fs = $temp[1]
set avail_space = $temp[4]
set mount_point = $temp[6]

# Make sure available space is greater than required space.
if (! $df_bad && $required_space >= $avail_space) then
  echo ""
  echo "Required space:  $required_space KB"
  echo "Available space: $avail_space KB"
  echo "   On partition: $install_fs  Mounted on: $mount_point"
  echo ""
  echo "The available disk space is less than the disk space needed for the"
  echo "distribution.  Would you like to re-enter the temporary directory?"
  echo "Press <return> to re-enter, or free up some space and type 'n'"
  echo "to continue."
  set udefault = "y"
  source $admin_dir/prompt
  if ("$userin" == "y") goto tmp_dir_mark
  goto tmp_space_mark
endif

# Set up to remove the temporary directory.
set exit_files = "$exit_files $tmp_dir"

# cd to the temporary directory and extract the expected distribution
# directory from the archive.
echo ""
echo "Extracting distribution from archive to temporary directory..."
cd $tmp_dir
set dir = confluent-$install_version
(umask 22 ; tar xof $current_dir/$archive $dir)

# The distribution directory must now exist in the temporary directory.
# If not, abort.
if (! -d $dir) then
  echo ""
  echo "The distribution was not successfully extracted from the archive."
  echo "The temporary directory"
  echo ""
  echo "   $tmp_dir"
  echo ""
  echo "does not contain the following distribution directory:"
  echo ""
  echo "   $dir"
  echo ""
  goto cleanup_mark
endif

# Change the distribution directory to the temporary distribution directory.
set dist_dir = $tmp_dir/$dir

# cd to the temporary distribution directory and change the admin directory
# to this version.  Use an absolute path so scripts can be executed when
# we temporarily cd back to the original distribution directory.
cd $dist_dir
set admin_dir = $dist_dir/admin

# At this point, we are using the original version of install, but all
# other scripts will be executed out of the temporary directory.

#----------------------------------------------------------------------
# Initialize directories and mode
#----------------------------------------------------------------------

init_mark:

# Set the directories to their defaults.
set install_dir = /usr/local/confluent
set bin_dir = /usr/local/bin
set man_dir = /usr/local/man

# Save the default directory values.
# The default variables are used to set the default for getting
# a directory, possibly after getting an invalid result.
set install_dir_def = $install_dir
set bin_dir_def = $bin_dir
set man_dir_def = $man_dir

# Determine whether only status was requested.
@ do_status = ("$1" == "status")

# If only status was requested, get the configuration and output the
# installed products.
if ($do_status) goto config_mark

#----------------------------------------------------------------------
# Get configuration of distribution directory
#----------------------------------------------------------------------

# Get configuration information (e.g., $product) for product installation
# directories in the distribution directory.
# Old installations are not included.
set config_top = "."
set config_sfx = ""
set config_old = 0
source $admin_dir/conf_init
@ n_product = $#product

# The distribution directory must contain at least one product installation
# directory.  If not, abort.
if ($n_product == 0) then
  echo ""
  echo "The current directory"
  echo ""
  echo "   $current_dir"
  echo ""
  echo "does not contain any valid product installation directories."
  echo "Please change to the top-level distribution directory"
  echo "(e.g., /cdrom, /cdrom/cdrom0) and type:"
  echo ""
  echo "   $install_cmd"
  echo ""
  goto cleanup_mark
endif

# The current directory must be a distribution directory.
# If not, output the status of the directory.
if (! $config_dist) then
  echo ""
  echo "The current directory"
  echo ""
  echo "   $current_dir"
  echo ""
  echo "is not a valid top-level distribution directory.  It appears to be"
  echo "an installation directory containing installed products.  You cannot"
  echo "install products from this directory.  Please change to the top-level"
  echo "distribution directory (e.g., /cdrom, /cdrom/cdrom0) and type:"
  echo ""
  echo "   $install_cmd"
  set do_status = 1
  goto config_mark
endif

#----------------------------------------------------------------------
# Check machine and operating system consistency
#----------------------------------------------------------------------

# Warn the user if the machine and operating system do not match those for
# one of the top-level product installation directories.
set array_names = ("top_level" "osrel"      "osname"     "machine")
set string_data = ("1"         "`uname -r`" "`uname -s`" "`uname -m`")
source $admin_dir/match_arrays

if ($array_index == 0) then
  echo ""
  echo "You are attempting to install from a machine that does not match any"
  echo "of the machines and operating systems in the available product"
  echo "installation directories.  The installation will probably succeed."
  echo "However, you will be unable to install a license key and may not be"
  echo "able to run the products you are installing from this machine."
  echo ""
  echo "The following machines and operating systems were found in the"
  echo "available product installation directories in the current directory:"
  echo ""
  echo "   Directory: $current_dir"
  echo ""
  $admin_dir/format_line "   " "" "machine" $fmt_machine "system"
  $admin_dir/format_line "   " "" "-------" $fmt_machine "------"

  # Set up the string arrays to be checked for duplicates.
  set array_names = ("top_level" "osdescr" "machine_d")

  # Go through all product installation directories.
  @ i = 0
  while ($i < $n_product)
    @ i ++

    # Consider only top-level products.
    if (! $top_level[$i]) continue

    # Find the record in the arrays.
    set string_data = ("1" "$osdescr[$i]" "$machine_d[$i]")
    source $admin_dir/match_arrays

    # Skip the record if a duplicate was found earlier in the arrays
    # (it was already output).
    if ($array_index < $i) continue

    $admin_dir/format_line "   " "" "$machine_d[$i]" $fmt_machine \
                           "$osdescr[$i]"

  end

  echo ""
  echo "Do you want to proceed? [y|n]"
  set udefault = "y"
  source $admin_dir/prompt
  if ("$userin" != "y") goto cleanup_mark

endif

#----------------------------------------------------------------------
# Check permissions allowed by the umask
#----------------------------------------------------------------------

# Extract the permissions for user, group, and other.
# The umask is a decimal number representing an octal value.
@ um = `umask`
@ old_u = $um / 100
@ old_g = ($um / 10) % 10
@ old_o = $um % 10

# Determine whether any of the permissions prevent read or execute access.
@ prot_u = ($old_u & 5)
@ prot_g = ($old_g & 5)
@ prot_o = ($old_o & 5)

# Warn the user if any categories will not have correct access.
if ($prot_u || $prot_g || $prot_o) then

  # Set up permissions that will provide correct access.
  @ new_u = ($old_u & 2)
  @ new_g = ($old_g & 2)
  @ new_o = ($old_o & 2)
  set new_o = $new_u$new_g$new_o
  set new_g = $new_u$new_g$old_o
  set new_u = $new_u$old_g$old_o

  # Indicate the categories that would not have correct access.
  echo ""
  echo "Your current umask is $um.  This will prevent correct access to"
  echo "installed files by the following categories of users:"
  echo ""
  if ($prot_u) echo "  owner: use $new_u to grant access to owner"
  if ($prot_g) echo "  group: use $new_g to grant access to owner/group"
  if ($prot_o) echo "  other: use $new_o to grant access to owner/group/other"

  umask_mark:

  # Allow the user to specify an alternate umask.
  echo ""
  echo "Please press <return> to use the current umask, type a new umask value"
  echo "to use during the installation (see the suggested values above), or"
  echo "type 'exit' to exit this script."
  set udefault = "$um"
  source $admin_dir/prompt

  # The specified umask must be a 1- to 3-digit octal number.
  if (`echo $userin | sed -n -e '/^[0-7]\{1,3\}$/p'` == "") goto umask_mark

  # Set the umask.
  umask $userin

endif

#----------------------------------------------------------------------
# Get installation directory
#----------------------------------------------------------------------


# Banner.  Place this before the mark so we only get this once.
if ($paging) clear
echo ""
echo "----------------------------------------------------------------------"
echo "Installation Directory"
echo "----------------------------------------------------------------------"

install_dir_mark:

# Get the installation directory.
# Temporarily cd to the original distribution directory during get_dir so
# relative paths will work as expected when using a temporary distribution
# directory.
echo ""
echo "The recommended installation directory where all Confluent files"
echo "will be placed is:"
echo ""
echo "   $install_dir_def"
echo ""
echo "Is this OK?  If so, press <return>; otherwise, type the directory"
echo "in which you wish to install Confluent products."
set get_dir_def = "$install_dir_def"
set get_dir_type = "installation"
cd $current_dir
source $admin_dir/get_dir
cd $dist_dir
if ($return_result != 0) goto install_dir_mark
set install_dir = "$get_dir"

config_mark:

# Get configuration information for product installation directories in
# the installation directory.
# If only status was requested, use the distribution directory.
# If the installation directory matches the current directory, use the
# distribution directory in case it is temporary.
# Old installations are included.
if ($do_status) then
  set config_top = "$dist_dir"
else
  if ("$install_dir" == "$current_dir") then
    set config_top = "$dist_dir"
  else
    set config_top = "$install_dir"
  endif
endif
set config_sfx = "_i"
set config_old = 1
source $admin_dir/conf_init
@ n_product_i = $#product_i

# The installation directory must not be a distribution directory,
# except if only status was requested.
if ($config_dist_i && ! $do_status) then
  echo ""
  echo "The specified installation directory"
  echo ""
  echo "   $install_dir"
  echo ""
  echo "is a top-level distribution directory.  You cannot install products"
  echo "into this directory.  Please press <return> to re-specify the"
  echo "installation directory, or type 'exit' and <return> to exit this"
  echo "script."
  set udefault = ""
  source $admin_dir/prompt
  goto install_dir_mark
endif

#----------------------------------------------------------------------
# List installed products
#----------------------------------------------------------------------

# Check whether any top-level products are already installed.
set array_names = ("top_level_i")
set string_data = ("1")
source $admin_dir/match_arrays

# List any products that are already installed.
if ($array_index > 0) then
  echo ""
  if ($do_status) then
    if ($config_dist_i) then
      echo "The following products are available for installation from the"
      echo "current directory:"
    else
      echo "The following products are installed in the current directory:"
    endif
    echo ""
    echo "   Directory: $current_dir"
  else
    echo "The following products are already installed in the installation"
    echo "directory:"
    echo ""
    echo "   Directory: $install_dir"
  endif
  echo ""
  $admin_dir/format_line "   " "" \
                         "product" $fmt_product \
                         "version" $fmt_version \
                         "machine" $fmt_machine \
                         "system" $fmt_system \
                         "date"
  $admin_dir/format_line "   " "" \
                         "-------" $fmt_product \
                         "-------" $fmt_version \
                         "-------" $fmt_machine \
                         "------" $fmt_system \
                         "----"

  # List the installed top-level products.
  @ i = 0
  while ($i < $n_product_i)
    @ i ++
    if (! $top_level_i[$i]) continue
    $admin_dir/format_line "   " "" \
                           "$product_d_i[$i]" $fmt_product \
                           "$version_d_i[$i]" $fmt_version \
                           "$machine_d_i[$i]" $fmt_machine \
                           "$osdescr_i[$i]" $fmt_system \
                           "$date_install_i[$i]"
  end

  echo ""
else
  if ($do_status) then
    echo ""
    echo "There are no products installed in the current directory:"
    echo ""
    echo "   $current_dir"
    echo ""
  endif
endif

# Quit if only status was requested.
if ($do_status) source $admin_dir/exit

# Determine which of the products available for installation are already
# installed.
set installed = ($config_init)
set array_names = ("oshead_i" "product_i")
@ i = 0
while ($i < $n_product)
  @ i ++

  # Determine whether the product is already installed.
  set string_data = ("$oshead[$i]" "$product[$i]")
  source $admin_dir/match_arrays
  if ($array_index > 0) set installed[$i] = 1
end

#----------------------------------------------------------------------
# List products available for installation
#----------------------------------------------------------------------

# Check whether any top-level products are available for installation.
set array_names = ("top_level")
set string_data = ("1")
source $admin_dir/match_arrays

# Set up a map to convert product IDs to array indices.
set map = ($config_init)

# List the top-level products in the distribution directory.
# Count the number installed and uninstalled.
@ n_installed = 0
@ n_uninstalled = 0
if ($array_index > 0) then
  echo ""
  echo "The distribution directory contains the following products:"
  echo ""
  echo "   Directory: $current_dir"
  echo ""
  $admin_dir/format_line "   ID  " "" \
                         "product" $fmt_product \
                         "version" $fmt_version \
                         "machine" $fmt_machine \
                         "system"
  $admin_dir/format_line "   --  " "" \
                         "-------" $fmt_product \
                         "-------" $fmt_version \
                         "-------" $fmt_machine \
                         "------"

  # List the products.
  @ i = 0
  while ($i < $n_product)
    @ i ++

    # Consider only top-level products.
    if (! $top_level[$i]) continue

    # List an ID and add it to the map only for products that are not
    # already installed.
    if ($installed[$i]) then
      @ n_installed ++
      set idstr = ""
    else
      @ n_uninstalled ++
      set idstr = $n_uninstalled
      set map[$n_uninstalled] = $i
    endif

    $admin_dir/format_line "$idstr" 5 "  " "" \
                           "$product_d[$i]" $fmt_product \
                           "$version_d[$i]" $fmt_version \
                           "$machine_d[$i]" $fmt_machine \
                           "$osdescr[$i]"
  end
endif

# Explain entries without IDs as products already installed.
if ($n_installed > 0) then
  echo ""
  echo "Products in the above list without an ID number are already"
  echo "installed.  You must uninstall them before you can reinstall them."
endif

# If there are no uninstalled products, there is nothing left to do.
if ($n_uninstalled == 0) then
  echo ""
  echo "There are no products available for installation from the distribution"
  echo "directory:"
  echo ""
  echo "   $current_dir"
  echo ""
  source $admin_dir/exit
endif

# Explain entries with IDs.
echo ""
echo "Products in the above list with an ID number can be installed."

#----------------------------------------------------------------------
# Get products to install
#----------------------------------------------------------------------

install_mark:

# Find out which products the user wishes to install.
echo ""
echo "Please type a list of the ID numbers (separated by spaces) for the"
echo "products you wish to install, or 'exit' to exit."
set udefault = ""
source $admin_dir/prompt
if ("$userin" == "") goto install_mark

# Check each ID against the map.
# If it is not in the map, prompt again for the ID list.
# Otherwise, mark the product for installation.
set install = ($config_init)
foreach id ($userin)
  # Use a switch to safely test only numbers greater than 0.
  switch ($id)
    case [1-9]:
    case [1-9][0-9]:
    case [1-9][0-9][0-9]:
      if ($id <= $n_uninstalled) breaksw
    default:
      goto install_mark
  endsw

  set install[$map[$id]] = 1
end

#----------------------------------------------------------------------
# Mark products required by products being installed
#----------------------------------------------------------------------

required_mark:

# Mark for installation products required by products being installed.
# Repeat the process until all required products are marked.
# Mark products that are already installed and unmark them afterward to
# make sure that products required by installed products get marked.
# This should not be necessary, but is done just in case.
set found = 0
set array_names = ("oshead" "product" "install")
@ i = 0
while ($i < $n_product)
  @ i ++

  # Consider only products marked for installation.
  if (! $install[$i]) continue

  # Go through each required product.
  foreach id ($required[$i])

    # If the required product is not yet marked for installation,
    # indicate that one was found and mark it.
    set string_data = ("$oshead[$i]" "$id" "0")
    source $admin_dir/match_arrays
    if ($array_index > 0) then
      set found = 1
      set install[$array_index] = 1
    endif

  end

end

# If additional products were marked for installation, go through again.
if ($found) goto required_mark

# Unmark products that are already installed.
@ i = 0
while ($i < $n_product)
  @ i ++
  if ($installed[$i]) set install[$i] = 0
end

# Consider checking that all required products are either installed
# or marked for installation.  This is probably not necessary, since
# a missing required product indicates a corrupt distribution directory.

#----------------------------------------------------------------------
# Mark products being installed with need to install share directory
#----------------------------------------------------------------------

# Set cp_share for the first system marked for installation if
# a product is not already installed for any other system.
# This is used to determine when to add space for and install the
# share directory.
set cp_share = ($config_init)
@ i = 0
while ($i < $n_product)
  @ i ++

  # Consider only products marked for installation.
  if (! $install[$i]) continue

  # Skip if the product is already installed for any system.
  set array_names = ("product" "installed")
  set string_data = ("$product[$i]" "1")
  source $admin_dir/match_arrays
  if ($array_index > 0) continue

  # If this is the first system marked for installation of this product,
  # set cp_share.
  set array_names = ("product" "install")
  set string_data = ("$product[$i]" "1")
  source $admin_dir/match_arrays
  if ($array_index == $i) set cp_share[$i] = 1

end

#----------------------------------------------------------------------
# Check for update of top-level installation files and directories
#----------------------------------------------------------------------

# Get the version of the top-level distribution and installation directories.
set new = $install_version_n
set get_version_n = 0
set file = $install_dir/admin/get_version
if (-r $file) source $file
set old = $get_version_n

# Update the top-level installation files and directories only if the
# distribution version is greater than the installation version.
@ cp_top = ($new > $old)

#----------------------------------------------------------------------
# Check that existing directories are writable for products being installed
#----------------------------------------------------------------------

# Make a list of directories to check in the installation directory.
set dirs = ""

# Add the top-level directories if they are being updated.
if ($cp_top) set dirs = "$dirs $top_dirs"

# Add the product directories.
set array_names = ("product" "install")
@ i = 0
while ($i < $n_product)
  @ i ++

  # Consider only products marked for installation.
  if (! $install[$i]) continue

  # If this is the first system marked for installation for this product,
  # add the product directory.
  set string_data = ("$product[$i]" "1")
  source $admin_dir/match_arrays
  if ($array_index == $i) set dirs = "$dirs $product[$i]"

end

# Check each directory in the list.
# If it exists, it must be a writable directory.
set dirs_dw = ""
foreach dir ($dirs)
  set file = $install_dir/$dir
  if (-e $file) then
    if (! -d $file || ! -w $file) set dirs_dw = "$dirs_dw $file"
  endif
end

if ("$dirs_dw" != "") then
  echo ""
  echo "The following paths already exist, but are not writable directories:"
  echo ""
  foreach dir ($dirs_dw)
    echo "   $dir"
  end
  echo ""
  echo "Either the paths are not directories, or you do not have write"
  echo "permission to the directories.  Make sure these paths are writable"
  echo "directories and restart the installation."
  echo ""
  goto cleanup_mark
endif

#----------------------------------------------------------------------
# Get bin directory
#----------------------------------------------------------------------

# Banner.
if ($paging) clear
echo ""
echo "----------------------------------------------------------------------"
echo "Executable Directory"
echo "----------------------------------------------------------------------"

bin_dir_mark:

# Get the bin directory.
# Temporarily cd to the original distribution directory during get_dir so
# relative paths will work as expected when using a temporary distribution
# directory.
echo ""
echo "I will need to install executables into a directory that is part of"
echo "your executable search path (defined by the PATH environment variable)."
echo "Only soft links will be created in this directory."
echo "I recommend a standard directory that should already be in your"
echo "and your users' search paths.  The recommended directory is:"
echo ""
echo "   $bin_dir_def"
echo ""
echo "Is this OK?  If so, press <return>; otherwise, type the directory"
echo "in which you wish to install executables."
set get_dir_def = "$bin_dir_def"
set get_dir_type = "executable"
cd $current_dir
source $admin_dir/get_dir
cd $dist_dir
if ($return_result != 0) goto bin_dir_mark
set bin_dir = "$get_dir"

# Is the bin directory in the current path search?
set file_path = "$bin_dir"
set file_array = ($path)
source $admin_dir/match_path
if ($file_index == 0) then
  echo ""
  echo "The following executable directory is NOT in your current search path:"
  echo ""
  echo "   $bin_dir"
  echo ""
  echo "This may be OK if you INSTALL products under a different account than"
  echo "the one in which you will USE them, or if you intend to change your"
  echo "PATH environment variable."
  echo "Would you like to re-enter the executable directory?  Type 'y'"
  echo "to re-enter, anything else to continue with the installation."
  set udefault = "n"
  source $admin_dir/prompt
  if ("$userin" == "y") goto bin_dir_mark
endif

# Get the inode of the bin directory.
set file_name = "$bin_dir"
source $admin_dir/file_info
set bin_inode = $file_inode

#----------------------------------------------------------------------
# Get man pages directory
#----------------------------------------------------------------------

# Banner.
if ($paging) clear
echo ""
echo "----------------------------------------------------------------------"
echo "Manual Pages Directory"
echo "----------------------------------------------------------------------"

man_dir_mark:

# Get the man directory.
# Temporarily cd to the original distribution directory during get_dir so
# relative paths will work as expected when using a temporary distribution
# directory.
echo ""
echo "I will need to put man pages into a directory that is part of the UNIX"
echo "manual pages search path (defined by the MANPATH environment variable)."
echo "Only soft links will be created in this directory."
echo "The recommended directory is:"
echo ""
echo "   $man_dir_def"
echo ""
echo "Is this OK?  If so, press <return>; otherwise, type the directory"
echo "in which you wish to install man pages."
set get_dir_def = "$man_dir_def"
set get_dir_type = "man pages"
cd $current_dir
source $admin_dir/get_dir
cd $dist_dir
if ($return_result != 0) goto man_dir_mark
set man_dir = "$get_dir"

# Is the man directory in MANPATH?
if ($?MANPATH) then
  set man_path = `echo $MANPATH | sed -e 's/:/ /g'`
else
  set man_path = /usr/man
endif
set file_path = "$man_dir"
set file_array = ($man_path)
source $admin_dir/match_path
if ($file_index == 0) then
  echo ""
  echo "The following man pages directory is NOT in your manual pages path:"
  echo ""
  echo "   $man_dir"
  echo ""
  echo "This may be OK if you INSTALL products under a different account than"
  echo "the one in which you will USE them, or if you intend to change your"
  echo "MANPATH environment variable."
  echo "Would you like to re-enter the man pages directory?  Type 'y'"
  echo "to re-enter, anything else to continue with the installation."
  set udefault = "n"
  source $admin_dir/prompt
  if ("$userin" == "y") goto man_dir_mark
endif

# Get the inode of the man directory.
set file_name = "$man_dir"
source $admin_dir/file_info
set man_inode = $file_inode

#----------------------------------------------------------------------
# Check disk space
#----------------------------------------------------------------------

space_mark:

# Notify user we are about to figure sizes.
echo ""
echo "Please wait a moment while I check the available disk space..."

# Get the space required by products marked for installation.
# The space is the sum of the following:
#  1. The $admin_dir, doc, and license directories.
#  2. Each $product/$oshead directory being installed.
#  3. Required $product/share directories for products being installed.
@ required_space = 0

# Get the space required by the top-level files and directories if they
# are being updated.
# This will overestimate the required space if these directories already
# exist in the installation directory.
if ($cp_top) then
  foreach dir ($top_files $top_dirs)
    if ("$dir" == "admin") set dir = $admin_dir
    set temp = (`$du_cmd $dir`)
    @ required_space += $temp[1]
  end
endif

# Add the space required by the products marked for installation.
@ i = 0
while ($i < $n_product)
  @ i ++

  # Consider only products marked for installation.
  if (! $install[$i]) continue

  # Add the space required by the system directory.
  set temp = (`$du_cmd $product[$i]/$oshead[$i]`)
  @ required_space += $temp[1]

  # If it needs to be installed, add the space required by the share directory.
  if ($cp_share[$i]) then
    set temp = (`$du_cmd $product[$i]/share`)
    @ required_space += $temp[1]
  endif

end

# Convert the required space from blocks to kilobytes.
if ($du_blocks) @ required_space /= 2

# Get the available space.
set temp = (`$df_cmd $install_dir | sed -e 's/\-\([0-9]\{6\}\)/ 1\1/g'`)
@ i = $#temp - 5
set temp = ($temp[$i-])
set install_fs = $temp[1]
set avail_space = $temp[4]
set mount_point = $temp[6]

# Make sure available space is greater than required space.
if (! $df_bad && $required_space >= $avail_space) then
  echo ""
  echo "Required space:  $required_space KB"
  echo "Available space: $avail_space KB"
  echo "   On partition: $install_fs  Mounted on: $mount_point"
  echo ""
  echo "The available disk space is less than the disk space needed for the"
  echo "installation.  Please free up some space and then press <return> to"
  echo "continue, or type 'exit' to exit."
  set udefault = ""
  source $admin_dir/prompt
  goto space_mark
endif

#----------------------------------------------------------------------
# Recapitulate settings
#----------------------------------------------------------------------

# Banner.
if ($paging) clear
echo ""
echo "----------------------------------------------------------------------"
echo "Installation Configuration Summary"
echo "----------------------------------------------------------------------"
echo ""
echo "Directories:"
echo ""
echo "   installation: $install_dir"
echo "   executable:   $bin_dir"
echo "   man pages:    $man_dir"

# List top-level products marked for installation.
echo ""
echo "Products being installed:"
echo ""
$admin_dir/format_line "   " "" \
                       "product" $fmt_product \
                       "version" $fmt_version \
                       "machine" $fmt_machine \
                       "system"
$admin_dir/format_line "   " "" \
                       "-------" $fmt_product \
                       "-------" $fmt_version \
                       "-------" $fmt_machine \
                       "------"
@ i = 0
while ($i < $n_product)
  @ i ++
  if (! $install[$i] || ! $top_level[$i]) continue
  $admin_dir/format_line "   " "" \
                         "$product_d[$i]" $fmt_product \
                         "$version_d[$i]" $fmt_version \
                         "$machine_d[$i]" $fmt_machine \
                         "$osdescr[$i]"
end

echo ""
echo "Required space:  $required_space KB"
if ($df_bad) then
  echo "Available space: unknown"
else
  echo "Available space: $avail_space KB"
  echo "   On partition: $install_fs  Mounted on: $mount_point"
endif
echo ""
echo "----------------------------------------------------------------------"
echo ""
echo "The installation directory will contain the entire distribution for"
echo "the installed products."
echo ""
echo "The executable directory must be in the search path (PATH environment"
echo "variable) of anybody who will run the installed products.  Only soft"
echo "links will be created in the executable directory."
echo ""
echo "The man pages directory should be in the man pages search path (MANPATH"
echo "environment variable) of anybody who will need to access man pages."
echo "Only soft links will be created in the man pages directory."
echo ""
echo "The installation will not remove previously installed products.  However,"
echo "links to these products may be renamed in the executable directory."
echo "Changes made to existing link names will be listed at the end of the"
echo "installation."
echo ""
echo "Up to this point, no files have been installed in your file system."
echo "Once the installation begins, you will not be able to interrupt it."
echo "Press <return> to begin the installation, anything else to exit."

set udefault = ""
source $admin_dir/prompt

# For safety, if user typed anything other than plain <return>, abort.
if ("$userin" != "") goto cleanup_mark

# Disable interrupts.
set enable_intr = 0
onintr -

if ($paging) clear

#----------------------------------------------------------------------
# Install top-level directories
#----------------------------------------------------------------------

# Get the installation date.
set date = `date '+%D %H:%M'`

# If the license directory does not exist, remove it (in case it is a link
# to a nonexistent file) and create it.
# Make sure the directory has full permission.
set dir = $install_dir/license
if (! -d $dir) then
  rm -f $dir
  mkdir $dir
endif
chmod 777 $dir

# If the license directory was removed, the above will at least make sure
# it exists. However, files will not be copied in unless the distribution
# is newer than the current installation. Currently, there are no essential
# files from the distribution that must exist in the license directory.

# Update the top-level installation files and directories.
if ($cp_top) then

  echo ""

  # Copy the top-level distribution files over the installation versions.
  # This will replace duplicate files.
  # Make all files readable.
  echo "Copying top-level files:"
  echo -n " "
  foreach file ($top_files)
    echo -n " $file"
    cp $file $install_dir
    set set_path = $install_dir/$file
    source $admin_dir/set_mode
  end
  echo ""

  # Remove the old admin directory and copy the distribution version.
  # Use the full destination path in case $admin_dir is a copy that does
  # not end in "/admin".
  # Make all files in the directory readable.
  set dir = $install_dir/admin
  if (-e $dir) then
    echo "Removing admin..."
    rm -rf $dir
  endif
  echo "Copying files to admin..."
  cp -r $admin_dir $dir
  set set_path = $dir
  source $admin_dir/set_mode

  # Remove the distribution directory marker.
  rm -f $dir/distribution

  # If the license directory already exists, remove old licensing form
  # documents.  There are now generic versions in the doc directory.
  set dir = $install_dir/license
  if (-d $dir) then
    set files = "$dir"/'vt_*_license.{ps,txt}'
    set nonomatchset = $?nonomatch
    set nonomatch
    set temp = `glob "$files"`
    if ("$temp" != "$files") then
      echo "Removing old licensing forms from license"
      rm -f $files
    endif
    if (! $nonomatchset) unset nonomatch
  endif

  # Save the customer.txt file if it exists.
  set save_customer = 0
  set base = license/customer.txt
  set file = $install_dir/$base
  if (-e $file) then
    echo "Saving old $base"
    set save_customer = 1
    mv $file $install_dir
  endif

  # Copy the top-level distribution directories (except admin) over the
  # installation directories.
  # This will replace duplicate files.
  # Make all files in the directories readable.
  foreach file ($top_dirs)
    if ("$file" == "admin") continue
    set dir = $install_dir/$file
    echo "Copying files to $file..."
    cp -r $file $dir:h
    set set_path = $dir
    source $admin_dir/set_mode
  end

  # Restore the customer.txt file.
  if ($save_customer) then
    set file = license/customer.txt
    echo "Restoring old $file"
    mv $install_dir/$file:t $install_dir/$file:h
  endif

endif

#----------------------------------------------------------------------
# Update old installations
#----------------------------------------------------------------------

set first = 1

# Remove an old install script from the installation directory.
set file = $install_dir/install
if (-e $file) then
  echo ""
  echo "Updating old installations"
  set first = 0

  echo "  Removing install"
  rm -f $file
endif

# If an old uninstall script exists in the installation directory.
set file = $install_dir/uninstall
set bin_dir_old = ""
set man_dir_old = ""
if (-e $file) then

  if ($first) then
    echo ""
    echo "Updating old installations"
  endif

  # Extract the old executable and man pages directories from uninstall.
  eval `sed -n -e 's/^ *set *bin_dir *=/set bin_dir_old = /p' $file`
  eval `sed -n -e 's/^ *set *man_dir *=/set man_dir_old = /p' $file`

  # Remove uninstall.
  echo "  Removing uninstall"
  rm -f $file

  # Install config files for old installed products.
  # Those configured by conf_init using the old config directory will have:
  #  1. An existing $product_i/$oshead_i directory.
  #  2. No $product_i/$oshead_i/config/system.dat file.
  #  3. An empty value for $bin_install_i.
  #  4. product.dat and system.dat in $admin_dir/old/$product_i.
  # It is implicitly assumed that subdirectories of the installation
  # directory are writable.
  @ i = 0
  while ($i < $n_product_i)
    @ i ++

    # Skip if $bin_install_i is not empty.
    if ("$bin_install_i[$i]" != "") continue

    # If product.dat does not exist in the installation directory, copy
    # the share directory.
    # This will replace duplicate files, although none should exist.
    # Make all files in the directory readable.
    set dir = $product_i[$i]/share
    set share_dist = $admin_dir/old/$dir
    set share_inst = $install_dir/$dir
    set file = config/product.dat
    if (! -e $share_inst/$file) then
      echo "  Adding $dir/$file"
      cp -r $share_dist $share_inst:h
      set set_path = $share_inst
      source $admin_dir/set_mode
    endif

    # Copy the system config directory.
    # Make all files in the directory readable.
    set dir = $product_i[$i]/$oshead_i[$i]/config
    set system_dist = $admin_dir/old/$dir
    set system_inst = $install_dir/$dir
    echo "  Adding $dir/system.dat"
    cp -r $system_dist $system_inst:h
    set set_path = $system_inst
    source $admin_dir/set_mode

    # Modify the installation date and executable and man pages directories
    # in system.dat.
    set file = $system_inst/system.dat
    if (-e $file) then
      cp $file $file.tmp
      sed -e '/^ *set *ci_date_install *=/s;=.*$;= "'"$date_install_i[$i]"'";' \
          -e '/^ *set *ci_bin_install *=/s;=.*$;= "'"$bin_dir_old"' 0";' \
          -e '/^ *set *ci_man_install *=/s;=.*$;= "'"$man_dir_old"' 0";' \
          $file.tmp > $file
      rm $file.tmp
    endif

    # If license.txt exists, copy the information to license/customer.txt.
    set src = license.txt
    set dst = license/customer.txt
    set file = $system_inst/$src
    if (-e $file) then
      echo "  Copying $dir/$src to $dst"
      sed -e 's/^\([cC]-[0-9]\{4\}\)-\([0-9][0-9]\)[0-9][0-9]$/\1\2/' \
          $file > $install_dir/$dst
    endif

  end

endif

#----------------------------------------------------------------------
# Install products
#----------------------------------------------------------------------

# Initialize the list of old and new executable link names.
set links_old = ""
set links_new = ""

# Go through each product.
@ i = 0
while ($i < $n_product)
  @ i ++

  # Consider only products marked for installation.
  if (! $install[$i]) continue

  echo ""
  echo "Installing $product_d[$i] $version_d[$i] for $osdescr[$i]"

  # Set up the distribution product, system, and share directory paths.
  set product_dist = $product[$i]
  set system_dist = $product_dist/$oshead[$i]
  set share_dist = $product_dist/share

  # Set up the installation product, system, and share directory paths.
  set product_inst = $install_dir/$product[$i]
  set system_inst = $product_inst/$oshead[$i]
  set share_inst = $product_inst/share

  # Create the installation product directory if necessary and set mode=go+rx.
  if (! -e $product_inst) then
    set dir_wanted = "$product_inst"
    source $admin_dir/create_dir
  endif

  # Do the following only if the share directory needs to be installed.
  if ($cp_share[$i]) then

    # Copy the share directory from the distribution to the installation.
    echo "  Copying files to $share_dist..."
    cp -r $share_dist $share_inst:h
    set set_path = $share_inst
    source $admin_dir/set_mode

    # Modify the value of top_dir in command scripts.
    set dir = $share_inst/bin
    set first = 1
    foreach cmd ($commands[$i])
      set file = $dir/$cmd
      if (! -e $file) continue

      if ($first) then
        echo "  Modifying command scripts in $share_dist/bin:"
        echo -n "   "
        set first = 0
      endif
      echo -n " $cmd"

      cp $file $file.tmp
      sed -e '/^ *set *top_dir *=/s;=.*$'";= $product_inst;" $file.tmp > $file
      rm $file.tmp
    end
    if (! $first) echo ""

    # Modify the top document path in documents.
    set first = 1
    foreach doc ($documents[$i])
      set dir = $share_inst/$doc:h
      if (! -d $dir) continue

      if ($first) then
        echo "  Modifying documents in ${share_dist}:"
        echo -n "   "
        set first = 0
      endif
      echo -n " $doc:h"

      set file = $doc:t
      $admin_dir/modify_docs $dir $file
    end
    if (! $first) echo ""

  endif

  # Copy the system directory from the distribution to the installation.
  echo "  Copying files to $system_dist..."
  cp -r $system_dist $system_inst:h
  set set_path = $system_inst
  source $admin_dir/set_mode

  # Modify the installation date and executable and man pages directories
  # in system.dat.
  set file = $system_inst/config/system.dat
  if (-e $file) then
    echo "  Modifying $system_dist/config/system.dat"

    cp $file $file.tmp
    sed -e '/^ *set *ci_date_install *=/s;=.*$;= "'"$date"'";' \
        -e '/^ *set *ci_bin_install *=/s;=.*$;= "'"$bin_dir $bin_inode"'";' \
        -e '/^ *set *ci_man_install *=/s;=.*$;= "'"$man_dir $man_inode"'";' \
        $file.tmp > $file
    rm $file.tmp
  endif

  # Create links to the executable directory.
  set dir = $share_inst/bin
  set first = 1
  foreach cmd ($commands[$i])

    # Set up the link target.
    set file = $dir/$cmd

    # Get a list of links matching the command in the executable directory.
    set link_base = $bin_dir/$cmd
    set link_version = ""
    set link_product = "$product[$i]"
    source $admin_dir/get_links

    # Determine whether an exact match was found.
    set array_names = ("link_path")
    set string_data = ("$link_base")
    source $admin_dir/match_arrays

    # If a matching link was found with a different target, rename it to the
    # next available, create a new link, and save the old and new names.
    # Remove the next available first in case there were none available.
    # Also create a new link if no matching link was found.
    set create = 1
    if ($array_index > 0) then
      set file_path = $file
      set file_array = ($link_target[$array_index])
      source $admin_dir/match_path
      if ($file_index > 0) then
        set create = 0
      else
        rm -f $link_next
        mv $link_base $link_next

        set links_old = "$links_old $cmd"
        set links_new = "$links_new $link_next:t"
      endif
    endif

    # Create the new link.
    if ($create) then

      if ($first) then
        echo "  Creating links in the executable directory:"
        echo "    $bin_dir"
        echo -n "     "
        set first = 0
      endif
      echo -n " $cmd"

      ln -s $file $link_base
    endif
  end
  if (! $first) echo ""

  # Create links to the man pages directory.
  set dir = $share_inst/man
  set first = 1
  foreach man ($man_pages[$i])

    if ($first) then
      echo "  Creating links in the man pages directory:"
      echo "    $man_dir"
      echo -n "     "
      set first = 0
    endif
    echo -n " $man"

    # Get the section number.
    set section = $man:e

    # Set up the link path.
    set file = $man_dir/man$section/$man

    # Create the section subdirectory if necessary and set mode=go+rx.
    if (! -e $file:h) then
      set dir_wanted = "$file:h"
      source $admin_dir/create_dir
    endif

    # Remove any old link and create the new link.
    rm -f $file
    ln -s $dir/$man $file
  end
  if (! $first) echo ""

end

#----------------------------------------------------------------------
# Exit
#----------------------------------------------------------------------

# Done.
echo ""
echo "Done."
echo ""
echo "You have successfully installed Confluent products."

# Indicate any renamed links in the executable directory.
if ("$links_old" != "") then
  echo ""
  echo "Links were renamed for some previously installed products.  The names"
  echo "of the following links were changed in the executable directory:"
  echo ""
  echo "   Directory: $bin_dir"
  echo ""
  $admin_dir/format_line "   " "" "old name" $fmt_command "new name"
  $admin_dir/format_line "   " "" "--------" $fmt_command "--------"

  # Convert the old and new name lists to arrays.
  set links_old = ($links_old)
  set links_new = ($links_new)

  # List the name changes.
  @ n = $#links_old
  @ i = 0
  while ($i < $n)
    @ i ++
    $admin_dir/format_line "   " "" \
                           "$links_old[$i]" $fmt_command \
                           "$links_new[$i]"
  end
endif

# List commands for products just installed.
echo ""
echo "You can now run the products you just installed, even without a license."
echo "Without a valid license, a product will run in 'Demonstration Mode', in"
echo "which all features are fully enabled except for saving."
echo ""
echo "The products you just installed can be run with the commands shown in"
echo "the last column of the following table:"
echo ""
$admin_dir/format_line "   " "" \
                       "product" $fmt_product \
                       "version" $fmt_version \
                       "machine" $fmt_machine \
                       "system" $fmt_system \
                       "command"
$admin_dir/format_line "   " "" \
                       "-------" $fmt_product \
                       "-------" $fmt_version \
                       "-------" $fmt_machine \
                       "------" $fmt_system \
                       "-------"
@ i = 0
while ($i < $n_product)
  @ i ++
  if (! $install[$i] || ! $top_level[$i]) continue
  set temp = ($commands[$i])
  if ($#temp == 0) set temp = ("")
  $admin_dir/format_line "   " "" \
                         "$product_d[$i]" $fmt_product \
                         "$version_d[$i]" $fmt_version \
                         "$machine_d[$i]" $fmt_machine \
                         "$osdescr[$i]" $fmt_system \
                         "$temp[1]"
end

# Encourage the user to read the files in the doc directory.
echo ""
echo "Be sure to look at the files in the following documentation directory:"
echo ""
echo "   $install_dir/doc"
echo ""
echo "They contain important information, including release notes, usage notes,"
echo "technical notes, and various forms used for licensing.  The file README"
echo "describes the other files available in this directory."

# Indicate how to get a license.
echo ""
echo "To license a product, please follow the instructions in the product's"
echo "Installation and Licensing Guide (supplied with your CD-ROM)."
echo ""
echo "You can get your server code at any time by typing:"
echo ""
echo "   confluent_a code"
echo ""
echo "from the machine that will be your license server host."
echo ""
echo "You will need to supply your server code to Confluent or your reseller"
echo "if you intend to obtain a permanent license for a product."

# Get the server code, or "error" if confluent_a fails (e.g., if the
# installation is being performed on a system for which the command is
# not available.
set code = "`($bin_dir/confluent_a code || echo error) | tail -1`"

# If the server code was obtained, tell the user.
if ("$code" != "error") then
  echo ""
  echo "The server code for the current machine is:"
  echo ""
  echo "   $code"
endif

echo ""
echo "We at Confluent sincerely hope and expect that you find"
echo "these products both useful and enjoyable."

source $admin_dir/exit

#----------------------------------------------------------------------
# Cleanup
#----------------------------------------------------------------------
cleanup_mark:

source $admin_dir/abort
