# inst_init - Initialize for install and uninstall.
#
# Version 1.3
#
# Pre:
#    admin_dir - directory containing administration scripts
# Post:
#    current_dir - current directory path
#    top_files - list of files in a top-level distribution directory
#    top_dirs - list of directories in a top-level distribution directory
#    uprompt - prompt value
#    paging - 1 => page is cleared periodically
#    enable_intr - 1 => use onintr to abort on interrupt in sourced scripts
#    install_version - abbreviated version of top-level directories
#    install_version_d - full version of top-level directories
#    install_version_n - numeric version of top-level directories
#    system => operating system (e.g., "sunos")
#    du_cmd - du command to yield kilobytes
#    du_blocks - 1 => du output in blocks (1/2 KB)
#    df_cmd - df command to yield kilobytes
#    df_bad - 1 => df cannot obtain information for a single partition
#
# This routine is sourced from csh.
#
# It uses the following utility scripts:
#   abort - abort and exit the top csh script
#   get_version - get the version of the admin, doc, and license directories
#
# Copyright (c) 1995 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: 950116 - jag
# Modified: 950314 - jag : Initialize enable_intr
# Modified: 950422 - jag : Set system, use new get_version
# Modified: 950825 - jag : Set du_cmd, du_blocks, df_cmd
# Modified: 970423 - jag : Add LICENSE, SUPPORT, release.txt to top_files
# Modified: 970503 - jag : Set du_bad
# Modified: 970731 - jag : Change LICENSE/SUPPORT to license.txt/support.txt

onintr cleanup_mark

# Get the current directory path.
set current_dir = `pwd`

# Set the lists of files and directories at the top level of a distribution.
set top_files = "README license.txt release.txt support.txt"
set top_dirs = "admin doc license"

# Set up the user prompt.
set uprompt = "->"

# Paging.  Set to 1 if we should clear the page periodically, 0 otherwise.
# In general, set to 0 because otherwise the repeat of the user's input
# gets wiped off the screen.
set paging = 0

# Interrupts.  Set to 1 if onintr used to abort on interrupt in sourced scripts.
set enable_intr = 1

# Set the version to the version of the top-level directories.
set get_version = "0.1"
set get_version_d = "0.1"
set get_version_n = 10
source $admin_dir/get_version
set install_version = "$get_version"
set install_version_d = "$get_version_d"
set install_version_n = $get_version_n

# Set the default system value.
set system = "unknown"

# Get the system information.
set ii_uname_s = "`uname -s`"
set ii_uname_r = "`uname -r`"

# Switch on the system name.
switch ("$ii_uname_s")

  case "HP-UX":

    set system = "hpux"
    breaksw

  case "SunOS":

    # Switch on the system release.
    switch ("$ii_uname_r")

      case "4.*":
        set system = "sunos"
        breaksw

      case "5.*":
        set system = "solaris"
        breaksw

      default:

    # "$ii_uname_r"
    endsw

    # "SunOS"
    breaksw

  default:

# "$ii_uname_s"
endsw

# Initialize the default du and df commands.
# These may not work on currently unrecognized systems.
set du_cmd = "du -s"
set du_blocks = 0
set df_cmd = "df"
set df_bad = 0

# Change the du and df commands for some systems to yield kilobytes.
switch ($system)

  case "hpux":
    set du_blocks = 1
    set df_cmd = "bdf"
    breaksw

  case "solaris":
    set du_cmd = "du -k -s"
    set df_cmd = "df -k"
    breaksw

  case "sunos":
    breaksw

  default:
endsw

# Determine whether the df command can obtain information for a single
# partition.
set ii_lines = `$df_cmd $current_dir | grep '%' | wc -l`
if ($ii_lines > 1) set df_bad = 1

# Return.
exit

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

source $admin_dir/abort
