#!/bin/csh -f
#
# Copyright (c) 1998, 2009, Oracle and/or its affiliates.All rights reserved. 
#
#   NAME
#    unix_cd_setup (shipped as <cd-rom>/setup)
#
#   DESCRIPTION
#     UNIX CD-ROM pre-installation setup tool
#
#   MODIFIED   (MM/DD/YY)
#   jwadleig   02/13/09 - (bug 8248541) by default use new obparameters file
#   jwadleig   10/02/07 - Put request for system name under QUERYPKG env. variable 
#   jwadleig   06/04/07 - merge all changes from 10.1.0.3.1 ports to mainline
#   jwadleig   03/30/07 - remove all OS versions from install query
#   jwadleig   11/29/06 - fix HP version number should 11.11 not 11.1
#   jwadleig   11/21/06 - fix version printing to strip of the ".rel" file extension.
#   jwadleig   08/31/06 - update for linux64 and fix bug-5526389 which was a merge
#                         issue from the rb3.1 merge eons ago#.                         
#   jwadleig   08/01/06 - add support for linuxia64 and linux86_64
#   rvullika   06/26/06 - (bug 5354915) List only the OS available on 
#                         the particular CD
#   rvullika   06/01/06 - Remove reference to software load key
#   rvullika   05/16/06 - some more text fixes
#   rvullika   01/24/06 - Some text fixes
#   rvullika   01/09/06 - s/Oracle Backup Media Management Installation Guide/
#                         Oracle Secure Backup Installation Guide
#   rvullika   12/12/05 - Mask out solaris 32 temporarily
#   rvullika   10/18/05 - Mask out aix & hp-ux temporarily
#   rvullika   05/25/05 - Add HP-UX(64) and AIX (64)
#   rvullika   07/19/05 - Fix the OB release string parsing logic
#   tdziedzi   05/18/05 - Product name change 
#   rvullika   04/21/05 - s/Oracle Backup Installation Guide/
#                         Oracle Backup Media Management Installation Guide 
#   rvullika   04/14/05 - fixed the "rb dir" grep expression
#   pmaseedu   01/19/05 - change "administrative host" to "administrative 
#                         server" in user-facing text 
#   rvullika   01/03/05 - Fix the architecture names
#   rvullika   10/18/04 - Cleanup unsupported architectures
#   rvullika   10/12/04 - Replace linux86-lfs with linux32
#   rvullika   07/29/04 - removed db2asc/asc2db
#   rvullika   07/14/04 - Copy db2asc & asc2db into installtion dir 
#   rvullika   07/06/04 - prevent overlay of RB with OB
#   rvullika   06/11/04 - Added solaris64
#   tdziedzi   06/08/04 - Remove 'licensed' comment 
#   tdziedzi   05/19/04 - Executables name change 
#   tdziedzi   03/05/04 - Update vendor/product name, copyright info 
#
# ******************************************************************************
#  Old changes (pre ade migration):
#     04/16/03 jrw  preserve any extant copy of rbparameters.
#     03/11/03 pfg  removed admin references.
#     08/23/02 jrw  install doc directory.
#     08/20/02 jrw  expect .tz, not encrypted .tze files; no more customer code nor
#                   load key nor cd decode tool.
#     07/24/02 jrw  use consistent terminology.  Also, given that "web server" is
#                   listed exactly when administrative host is listed, display just
#                   administrative host.
#     07/05/02 jrw  change "RB" in user-visible text to "Reliaty Backup".  Update
#                   copyright.  Remove unused platform types.
#     02/21/02 jrw  support NetBSD.
#     12/19/01 gms  s/gui/web server/.
#     12/18/01 gms  more v3 mods.
#     12/14/01 gms  v3 mods.
#     09/21/01 jrw  fix for HP (uppercase, semicolons, no dot).
#     09/13/01 jrw  handle once-extant, now-absent packages to which load key refers.
#     08/13/01 jrw  add Debian Linux support.
#     06/27/01 jrw  support linux86-lfs.
#     06/22/01 jrw  support v5 of easy cd creator.
#     11/16/00 cmg  change logic to check for end of table when gathering platform names.
#     05/28/00 jrw  support FreeBSD 3 and later (ELF), SuSE Linux.
#     01/12/00 jrw  remove hp68.
#     01/07/00 jrw  allow user to set temp directory.
#     11/11/99 jrw  don't permit qrrel to be of the form "<n>.<m>.", rather
#                   elide trailing dot.
#     08/31/99 jrw  correct detection of $cwd == recommended dir.
#     01/05/98 jrw  accommodate trailing dot in lowercase solaris file names.
#     12/20/98 jrw  original coding.


#  Set path explicitly:
#
set path = (. install /usr/ucb /usr/sbin /usr/bin /sbin /bin /usr/etc /etc /usr/bsd)


#  Initialization...  some of this is needed to use the standard installation
#  tools' subprograms from setup.
#
set cdtools = "$cwd/.ob_cdtools"
setenv idir $cdtools

setenv OBTRACE 0


#  Argument processing:
#
while ($#argv > 0)
    set arg = "$1"
    shift
    if ("$arg" == "-y") then
        setenv OBTRACE 1
    else if ("$arg" == "-t") then
        if ($#argv > 0) then
            set ob_tmp = "$1"
            shift
            if (! -d $ob_tmp) then
                echo "temp directory $ob_tmp doesn't exist"
                exit (1)
                endif
        else
            echo "-t requires a pathname argument (the temp directory)"
            exit (1)
            endif
    else if ("$arg" == "-s") then
        if ($#argv > 0) then
            setenv CDROM_PROGDIR "$1"
            shift
            if (! -d $CDROM_PROGDIR) then
                echo "source directory directory $CDROM_PROGDIR doesn't exist"
                exit (1)
                endif
        else
            echo "-s requires a pathname argument (the source directory)"
            exit (1)
            endif
    else
        echo "unrecognized argument, $arg"
        exit (1)
        endif
    end


#  Setup temp directory:
#
if ($?ob_tmp) then
    setenv OB_TMP "$ob_tmp"
else if (-d /usr/tmp) then
    setenv OB_TMP /usr/tmp
else if (-d /tmp) then
    setenv OB_TMP /tmp
else
    setenv OB_TMP "."
    endif


#  Alphabets for tr(1):
#
set lowerchars  = "abcdefghijklmnopqrstuvwxyz"
set upperchars  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"


#  Other general initialization:
#
set ccode_dft       = "./.ob_ccode"
set ikey_dft        = "./.ob_ikey"
setenv CDROM_SETUP    1


#  Discover program directory -- this should be either the CD-ROM, or a
#  CD-ROM image.
#
set prog = "$0"
set progdir = "$prog:h"
if ("$prog" == "$progdir") set progdir = "."
if ($?CDROM_PROGDIR) then
    set progdir = $CDROM_PROGDIR
    endif
pushd $progdir >&/dev/null
if ($status) then
    echo -n "ERROR: can't change directory to ${progdir}: "
    pushd $progdir
    exit (1)
    endif
set progdir = "$cwd"


#  Figure out which naming scheme is used by this operating system to identify
#  files on the CD-ROM.  For files, it's one of:
#    a. lowercasename
#    b. lowercasename[.]    trailing dot appended if name contains no "."
#    c. UPPERCASENAME
#    d. UPPERCASENAME[.];1  dot inserted if name contains no "."
#
#  For directories, it's one of:
#    a. lowercasename
#    b. UPPERCASENAME

set nonomatch
set obrel   = `echo *.rel`
if ("$obrel" != '*.rel') then
    set cdnaming = lc
else
    set obrel   = `echo *.REL`
    if ("$obrel" != '*.REL') then
        set cdnaming = uc
    else
        set obrel   = `echo "*.REL;1"`
        if ("$obrel" != '*.REL;1') then
            set cdnaming = ucs
        else
            echo "Can't find release identifier file on CD-ROM (in $progdir)."
            exit (1)
            endif
        endif
    endif


#  Accommodate trailing dot on lowercase names without extensions
#  for Solaris:
#
if ($cdnaming == lc  && ! -f setup     && -f setup.    ) set cdnaming = lcd


#  Accommodate uppercase-semi-without-dot for HP-UX:
#
if ($cdnaming == ucs && ! -f 'SETUP;1' && -f 'SETUP.;1') set cdnaming = ucsd


popd >&/dev/null
unset nonomatch


#  Determine the version number of Oracle Secure Backup contained on this CD-ROM for user consumption:
#
set obrel_list = `echo $obrel | sed -e 's/[.]/ /g'`
@ i = 2 
while ($i < $#obrel_list) 
    if ($i == 2) then
        set obrel = $obrel_list[$i]
    else
        set obrel = $obrel.$obrel_list[$i]
        endif
    @ i = $i + 1 
    end


#  Setup some useful CD-ROM pathnames:
#
switch ($cdnaming)
    case lc:
        set install_tar     = "$progdir/install.tar"
        set doc_tar         = "$progdir/doc.tar"
        set ayenay_src      = "$progdir/cdtools/ayenay.sh"
        set canbe_src       = "$progdir/cdtools/canbe"
        set machinfo_src    = "$progdir/cdtools/machinfo.sh"
        set mymachinfo_src  = "$progdir/cdtools/mymachin.sh"
        set justtokens_src  = "$progdir/cdtools/justtoke.sed"
        set munghpver_src   = "$progdir/cdtools/munghpve.sed"
        set hostinfo_leaf   = "hostinfo"
        breaksw
    case lcd:
        set install_tar     = "$progdir/install.tar"
        set doc_tar         = "$progdir/doc.tar"
        set ayenay_src      = "$progdir/cdtools/ayenay.sh"
        set canbe_src       = "$progdir/cdtools/canbe."
        set machinfo_src    = "$progdir/cdtools/machinfo.sh"
        set mymachinfo_src  = "$progdir/cdtools/mymachin.sh"
        set justtokens_src  = "$progdir/cdtools/justtoke.sed"
        set munghpver_src   = "$progdir/cdtools/munghpve.sed"
        set hostinfo_leaf   = "hostinfo."
        breaksw
    case uc:
        set install_tar     = "$progdir/INSTALL.TAR"
        set doc_tar         = "$progdir/DOC.TAR"
        set ayenay_src      = "$progdir/CDTOOLS/AYENAY.SH"
        set canbe_src       = "$progdir/CDTOOLS/CANBE"
        set machinfo_src    = "$progdir/CDTOOLS/MACHINFO.SH"
        set mymachinfo_src  = "$progdir/CDTOOLS/MYMACHIN.SH"
        set justtokens_src  = "$progdir/CDTOOLS/JUSTTOKE.SED"
        set munghpver_src   = "$progdir/CDTOOLS/MUNGHPVE.SED"
        set hostinfo_leaf   = "HOSTINFO"
        breaksw
    case ucs:
        set install_tar     = "$progdir/INSTALL.TAR;1"
        set doc_tar         = "$progdir/DOC.TAR;1"
        set ayenay_src      = "$progdir/CDTOOLS/AYENAY.SH;1"
        set canbe_src       = "$progdir/CDTOOLS/CANBE;1"
        set machinfo_src    = "$progdir/CDTOOLS/MACHINFO.SH;1"
        set mymachinfo_src  = "$progdir/CDTOOLS/MYMACHIN.SH;1"
        set justtokens_src  = "$progdir/CDTOOLS/JUSTTOKE.SED;1"
        set munghpver_src   = "$progdir/CDTOOLS/MUNGHPVE.SED;1"
        set hostinfo_leaf   = "HOSTINFO;1"
        breaksw
    case ucsd:
        set install_tar     = "$progdir/INSTALL.TAR;1"
        set doc_tar         = "$progdir/DOC.TAR;1"
        set ayenay_src      = "$progdir/CDTOOLS/AYENAY.SH;1"
        set canbe_src       = "$progdir/CDTOOLS/CANBE.;1"
        set machinfo_src    = "$progdir/CDTOOLS/MACHINFO.SH;1"
        set mymachinfo_src  = "$progdir/CDTOOLS/MYMACHIN.SH;1"
        set justtokens_src  = "$progdir/CDTOOLS/JUSTTOKE.SED;1"
        set munghpver_src   = "$progdir/CDTOOLS/MUNGHPVE.SED;1"
        set hostinfo_leaf   = "HOSTINFO.;1"
        breaksw
    endsw


#  Here are the names of the executable tools we use in this program:
#
set ayenay      = "$idir/ayenay.sh"
set canbe       = "$idir/canbe"
set machinfo    = "$idir/machinfo.sh"
set mymachinfo  = "$idir/mymachinfo.sh"
set justtokens  = "$idir/justtokens.sed"
set munghpver   = "$idir/munghpver.sed"

# Before we forget ... drop the ".rel" from the release string
#
set obrel = `echo $obrel | sed -e 's/.rel/ /g'`

#  Say "hi":
#
set sep = '-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -'
echo "Welcome to Oracle's setup program for Oracle Secure Backup.  This"
echo "program loads Oracle Secure Backup software from the CD-ROM to a"
echo "filesystem directory of your choosing."
if ($?obrel) then
    echo ""
    echo "This CD-ROM contains Oracle Secure Backup version $obrel."
    endif


#  Make an image of the CD-ROM "tools" directory under the local (ostensibly
#  Oracle Secure Backup) directory.  We do so in order to set the "execute" mode
#  bits on executables, something that isn't done for us on the CD-ROM image for
#  some UNIX platforms.
#
if (! -d $idir) then
    mkdir $idir
    if ($status) then
        echo "ERROR: can't make directory $idir."
        exit (1)
        endif
    endif


#  Copy tools we need from the CD-ROM to $idir:
#
cp $ayenay_src      $ayenay
cp $canbe_src       $canbe
cp $machinfo_src    $machinfo
cp $mymachinfo_src  $mymachinfo
cp $justtokens_src  $justtokens
cp $munghpver_src   $munghpver

chmod 777 $idir/*


echo ""
echo -n "Please wait a moment while I learn about this host..."

set no_mach_name
source $mymachinfo
if ($status) then
    echo "ERROR: can't determine sufficient info about this machine to continue."
    exit (1)
    endif
unset no_mach_name

echo " done."

if ($cdnaming == lc || $cdnaming == lcd) then
    set arch_leaf   = $my_mach_arch
else
    set arch_leaf   = `echo $my_mach_arch | tr $lowerchars $upperchars`
    endif


#  Handle dash-to-underscore name translation, if it took place:
#
if (! -d $progdir/$arch_leaf) then
    set narch_leaf = `echo $arch_leaf | sed -e 's,-,_,g'`
    if (-d $progdir/$narch_leaf) then
        set arch_leaf = "$narch_leaf"
    else
        echo "ERROR: can't find either $progdir/$arch_leaf or $progdir/$narch_leaf."
        exit (1)
        endif
    endif


set arch_tools      = $progdir/$arch_leaf
set etc_dir         = "$idir/../.etc.$my_mach_arch"


#  Make the .etc directory for this machine architecture if needed, so that
#  we can install the hostinfo program there.
#
if (! -d $etc_dir) then
    mkdir $etc_dir
    if ($status) then
        echo "ERROR: can't make $etc_dir."
        exit (1)
        endif
    endif


#  Be sure our user is in the right directory.
#

#  Make sure we aren't try an "in-place" upgrade from RB. That could cause problems
#  during uninstall of RB

   if (-f /etc/rbconfig) then
       set rbdir = `grep -i < /etc/rbconfig "^[  ]*rb dir:"`
       if (-d $rbdir[3]/bin && -d $rbdir[3]/etc) then
           setenv rb_installed 1
       else
           setenv rb_installed 0
           endif
       if (("$cwd" == "$rbdir[3]") && ($?rb_installed)) then
           echo "$sep"
           echo " "
           echo "An installation of Reliaty Backup has been detected on this host."
           echo "You are attempting an 'in-place' upgrade of Reliaty Backup"
           echo "to Oracle Secure Backup.  This type of upgrade is not supported."
           echo "Please create a separate Oracle Secure Backup directory (Oracle recommends"
           echo "/usr/local/oracle/backup), and re-run $prog with your current working"
           echo "directory set to the Oracle Secure Backup directory that you created."
           echo "See the Oracle Secure Backup Installation Guide for more"
           echo "information."
           exit (1)
           endif
       endif

echo $cwd | grep /usr/local/oracle/backup >&/dev/null
if ($status == 0) then
    set is_recommended_dir
    endif

if (-d bin && -d etc && -f .wrapper) then
    set updating_ob
    endif

if (! $?is_recommended_dir && ! $?updating_ob) then
    echo ""
    echo "Would you like to load the Oracle Secure Backup software into your"
    echo "current directory ${cwd}?"
    echo "(Oracle recommends using /usr/local/oracle/backup as the Oracle"
    echo "Secure Backup home)" 
    echo "A 'yes' answer proceeds to use the current directory [yes]: "
    set ayenay_dft = yes
    source $ayenay
    if (! $status) then
        echo ""
        echo "Please re-run $prog with your current directory set to the"
        echo "appropriate Oracle Secure Backup directory."
        exit (1)
        endif
    set tweek_obp_obdir
    endif

#  Build a list of all installable packages:
#
set pkgs = ()
@ i = 0
while (1)
    @ i += 1
    set par = "`$canbe $i -name`"
    if ("$par" == ENDOFLIST) break
    if ("$par" == ntx86 || "$par" == "" || (! -d $progdir/$par)) continue
    set pkgs = ($pkgs $i gs gc se cl)
    end

echo ""
echo "$sep"


#  Show the user what he or she can install on this machine:
#
while (1)
    unset my_mach_ix
    if $?QUERYPKG then
	echo "You may load any of the following Oracle Secure Backup packages:"
	endif
    @ ix = 1
    set plist = ()
    set elist = ()
    while ($ix <= $#pkgs)


        #  Get the architecture number from the list, then get the corresponding
        #  architecture name.  If we're loading software for this machine arch,
        #  remember the its index in the list.
        #
        set pno = $pkgs[$ix]
        set par = "`$canbe $pno -name`"


        #  If $par is blank, this architecture is no longer supported.  Remove
        #  it from the $pkgs[] list.
        #
        if ("$par" == "") then
            set ptemp = ()
            @ ixplus1 = $ix + 1
            @ jx = 1

            while ($jx <= $#pkgs)

                if ($jx == $ix || $jx == $ixplus1) then
                    @ jx += 1
                    continue
                    endif

                set ptemp = ($ptemp $pkgs[$jx])
                @ jx += 1
                end

            set pkgs = ($ptemp)
            unset ptemp jx ixplus1
            continue
            endif

        set plist = ($plist $ix)

        if ("$my_mach_arch" == "$par") set my_mach_ix = $#plist


        #  Ask canbe to produce a C-shell command that'll setup a list of
        #  variables indicating what this machine is capable of.  The intent
        #  here is to not invoke canbe 4 times, once per each roles for each
        #  architecture.
        #
        set setcmd = `$canbe $par -set`
        eval $setcmd


        #  See what roles for the current architecture this user is permitted to
        #  load from CD.  We exit the loop below with p_* set to 2 if the role is
        #  desired and permitted, any other numeric value to indicate that one or
        #  both of those conditions aren't true.
        #
        @ ix += 1
        while ($ix <= $#pkgs)
            set p_el = "$pkgs[$ix]"
            echo $p_el | grep '^[0-9][0-9]*$' >&/dev/null
            if ($status == 0) break
            @ ix += 1

            set testcmd = 'if ($p_'"$p_el"' == 1) set p_'"$p_el"' = 2'
            eval $testcmd
            end

        set pst = ""


        #  Uncomment the following line should it become the case that web server doesn't appear
        #  exactly when administrative host appears.
        #
        #       if ($p_gc == 2) set pst = "$pst, web server"


        if ($p_gs == 2) set pst = "$pst, administrative server"
        if ($p_se == 2) set pst = "$pst, media server"
        if ($p_cl == 2) set pst = "$pst, client"
        if ("$pst" == "") set pst = ". "

        set pst = `echo "$pst" | sed -e 's,^..\(.*\),\1,'`
        set elist = ($elist:q "$pst")

        set parx = "$par"
        unset do_nl

        if ($parx == "alphaosf") then
            set parx = "alphaosf (OSF1/Digital UNIX/Tru64, Alpha)"

        else if ($parx == "hpvxfs") then
            set parx = "hpvxfs"

        else if ($parx == "linux32") then
            set parx = "linux32"
            set do_nl

        else if ($parx == "linux86_64") then
            set parx = "linux86_64"
            set do_nl

        else if ($parx == "linuxia64") then
            set parx = "linuxia64"
            set do_nl

        else if ($parx == "rs6000") then
            set parx = "rs6000 (IBM AIX)"

        else if ($parx == "sco") then
            set parx = "sco (SCO UNIX, Intel)"

        else if ($parx == "solaris") then
            set parx = "solaris32 (Solaris 2.6 & later, SPARC)"
            set do_nl

        else if ($parx == "solaris64") then
            set parx = "solaris64 (SPARC)"
            set do_nl
   
        else if ($parx == "ibm64") then
            set parx = "ibm64 (AIX)"
            set do_nl    
    
        else if ($parx == "hp64pa") then
            set parx = "hp64pa (HP-UX PA-risc)"
            set do_nl

        else if ($parx == "hp64ia") then
            set parx = "hp64ia (HP-UX Itanium)"
            set do_nl
            endif

        if ($#plist < 10) echo -n " "
        if (! $?do_nl) then
            echo "   $#plist. $parx $pst"
        else 
            echo "   $#plist. $parx"
            echo "       $pst"
            endif
        end

    set dft = "all"
    if ($?my_mach_ix) then
        set dft = $my_mach_ix
        endif


#  Find out what we're to do:
#
    if $?QUERYPKG then
        echo ""
	echo "Enter a space-separated list of packages you'd like to load.  To load all"
	echo -n "packages, enter 'all' [$dft]: "
	set wants = "$<"
	if ("$wants" == "") set wants = "$dft"
    else
	set wants = "$dft"
	endif

    if ("$wants" == all) then
        set wants = ()
        @ ix = 1
        while ($ix <= $#plist)
            set wants = ($wants $ix)
            @ ix += 1
            end
        endif

    set wants = (`echo $wants`)

    unset fail
    @ ix = 1
    while ($ix <= $#wants)
        set item = "$wants[$ix]"
        @ ix += 1
        echo $item | grep '^[0-9][0-9]*$' >&/dev/null
        if ($status != 0) then
            echo "Please enter a list of package numbers or 'all'."
            set fail
            break
            endif
        if ($item < 1 || $item > $#plist) then
            echo "Your selection $item is out of range."
            set fail
            break
            endif
        end

    if (! $?fail) break
    end


#  Save a copy of the old obparameters file:
#
unset obpsaved
set obp = install/obparameters
if (-f $obp) then
    set obpsaved = "$obp.savedbysetup"
    cp $obp $obpsaved
    endif


#  Install the standard Oracle Secure Backup installation tools from the CD-ROM.  We need these to
#  do any real installation work.
#
echo ""
echo "$sep"
echo -n "Loading Oracle Secure Backup installation tools..."

unset fail
onintr intr_exit
set tempfile = $OB_TMP/OB$$

tar -xpf $install_tar
if ($status) set fail
echo " done."

if ($?fail) then
    echo "ERROR: couldn't load Oracle Secure Backup installation tools."
    exit (1)
    endif

if ($?fail) then
    echo "ERROR: couldn't load Oracle Secure Backup on-line documentation."
    exit (1)
    endif

#  If we're installing a new copy of Oracle Secure Backup on this host, update the
#  Oracle Secure Backup parameters file in the install directory to reflect the proper name
#  of the Oracle Secure Backup directory.
#
if ($?tweek_obp_obdir && ! $?obpsaved && -f $obp) then
    set lc_os_name = `echo $my_os_name | tr $upperchars $lowerchars`
    sed -e 's,^\('$lc_os_name'[ 	][ 	]*ob[ 	][ 	]*dir:[ 	][ 	]*\).*$,\1'$cwd',' $obp >$tempfile
    echo -n "Updating Oracle Secure Backup directory name for $my_os_name in $obp..."
    mv $tempfile $obp
    echo " done."
    endif


#  Loop to load Oracle Secure Backup software -- once around for each architecture.
#
@ ix = 1
while ($ix <= $#wants) 


    #  Get the index into the plist of what the user wants to load:
    #
    set want = $wants[$ix]
    @ ix += 1
    @ jx = $plist[$want]        # jx is packages list index


    #  Get the architecture number and architecture name the user wants:
    #
    set pno = $pkgs[$jx]
    set par = "`$canbe $pno -name`"


    #  Get the list of roles Oracle Secure Backup can play for this architecture:
    #
    set setcmd = `$canbe $par -set`
    eval $setcmd

    echo -n "Loading $par ${elist[$want]}..."


    #  Iterate below once for each role:
    #
    while ($jx < $#pkgs)
        @ jx += 1
        set p_el = "$pkgs[$jx]"
        echo $p_el | grep '^[0-9][0-9]*$' >&/dev/null
        if ($status == 0) break

        unset loadme
        set testcmd = 'if ($p_'"$p_el"' == 1) set loadme'
        eval $testcmd

        if (! $?loadme) continue

        switch ($p_el)
            case cl:
                set leaf = "client"
                breaksw
            case se:
                set leaf = "server"
                breaksw
            case gc:
                set leaf = "gclient"
                breaksw
            case gs:
                set leaf = "gserver"
                breaksw
            default:
                unset leaf
            endsw

        if (! $?leaf) continue
        set rhs = "${par}/$leaf.tz"
        if ($cdnaming == uc || $cdnaming == ucs || $cdnaming == ucsd) then
            set rhs = `echo $rhs | tr $lowerchars $upperchars`
            if ($cdnaming == ucs || $cdnaming == ucsd) set rhs = "$rhs;1"
            endif

        set src = "$progdir/$rhs"


        #  If a .tz file is missing from the CD-ROM, something nasty is up;
        #  we should have known this and not tried to install this file.
        #
        if (! -e $src) then
            set nsrc = `echo $src | sed -e 's,-,_,g'`
            if (-e $nsrc) then
                set src = "$nsrc"
            else
                echo -n " $leaf MISSING"
                continue
                endif
            endif

        cp $src $tempfile.Z
        if ($status) then
            echo ""
            echo "ERROR: can't copy $src to $tempfile.Z"
            rm -f $tempfile.Z >&/dev/null
            exit (1)
            endif

        uncompress $tempfile
        if ($status) then
            echo "ERROR: can't uncompress $tempfile"
            echo "    (made from $src)"
            echo ""
            echo "This is probably due to the "uncompress" utility being unavailable."
            echo "Make sure "uncompress" is available and then re-run "setup"."
            exit (1)
            endif
        tar -xpf $tempfile
        if ($status) then
            echo "ERROR: can't un-tar $tempfile"
            echo "    (made from $src)"
            exit (1)
            endif

        rm -f $tempfile


        #  Copy hostinfo from CD-ROM into .bin directory if we're installing a client:
        #
        if ($p_el == cl) then
            set rhs = "$par/$hostinfo_leaf"
            if ($cdnaming == uc || $cdnaming == ucs || $cdnaming == ucsd) set rhs = `echo $rhs | tr $lowerchars $upperchars`
            if (! -e $progdir/$rhs) set rhs = `echo $rhs | sed -e 's,-,_,g'`
            cp $progdir/$rhs .bin.$par/hostinfo
            chmod 777 .bin.$par/hostinfo
            endif
        end

    echo " done."
    end

#  Prior to 10.3 we would use the old version of the obparameters file if it existed.
#  At 10.3 there are changes in obparameters that are required.  The old obparameters file is
#  saved and we continue the install with the new one.  If the previous instance of obparameters
#  had been customized the user will need to do that manually.  No provision here to automatically
#  save those customizations.  
#
if ($?obpsaved) then
    echo " "
    echo "$sep"
    echo "Oracle Secure Backup has installed a new obparameters file."
    echo "Your previous version has been saved as $obp.savedbysetup."
    echo "Any changes you have made to the previous version must be"
    echo "made to the new obparameters file."
    echo " "
    echo "Would you like the opportunity to edit the obparameters file"
    echo -n "Please answer 'yes' or 'no' [no]: "
    set ayenay_dft = no
    source $idir/ayenay.sh
    if ($status != 0) then
        echo ""
        echo "Please edit the obparameters file."
        echo "When you are ready to continue:"
        echo " 1. log in as (or 'su' to) root"
        echo " 2. cd to $cwd"
        echo " 3. run install/installob"
        echo ""
        goto common_exit
        endif
    endif

echo ""
echo "$sep"
echo "Loading of Oracle Secure Backup software from CD-ROM is complete."
echo "You may unmount and remove the CD-ROM."
echo ""

setenv idir "./install"

#  Offer to run 'installob' for our user.
#
ask_config:

unsetenv my_os_name my_os_ver my_mach_arch my_base_arch my_mach_type my_mach_name my_f_mach_name

unset exec_installob

echo " "
echo "Would you like to continue Oracle Secure Backup installation with"
echo "'installob' now?  (The Oracle Secure Backup Installation Guide"
echo "contains complete information about installob.)"
echo -n "Please answer 'yes' or 'no' [yes]: "
set ayenay_dft = yes
source $idir/ayenay.sh
if ($status != 0) then
    echo ""
    echo "$sep"
    set exec_installob
else
    echo ""
    echo "When you are ready to continue:"
    echo " 1. log in as (or 'su' to) root"
    echo " 2. cd to $cwd"
    echo " 3. run install/installob"
    echo ""
    endif

goto common_exit


intr_exit:
set rval = 9


#  Common cleanup logic:
#
common_exit:


#  Delete all empty .etc directories:
#
set nonomatch
set etclist = (`echo .etc.*`)
set rmetclist = ()
if ("$etclist" != ".etc.*") then
    foreach etcdir ($etclist)
        pushd $etcdir >&/dev/null
        set filelist = (`echo *`)
        if ("$filelist" == '*') set rmetclist = ($rmetclist $etcdir)
        popd >&/dev/null
        end
    endif

unset nonomatch
if ($#rmetclist > 0) rm -rf $rmetclist

if (-d $cdtools) rm -rf $cdtools

if ($?tempfile) then
    rm -f $tempfile >&/dev/null
    endif


#  After cleanup we exec installob if asked to by our user:
#
if ($?exec_installob) exec $idir/installob

if (! $?rval) set rval = 0
exit ($rval)
