#!/bin/csh -f
#
# Copyright (c) 1992, 2005, Oracle. All rights reserved.  
#
#   NAME
#     installhost
#
#   DESCRIPTION
#     install Oracle Secure Backup onto a set of machines
#
#   MODIFIED   (MM/DD/YY) 
#   tdziedzi   05/18/05 - Product name change 
#   pmaseedu   01/11/05 - change "administrative host" to "administrative server"
#                         in user-facing text
#   pmaseedu   01/11/05 - Name change from admin/administrative 'host' to 
#                         'server'. 
#   tdziedzi   05/18/04 - Executables name change 
#   tdziedzi   03/05/04 - Update vendor/product name, copyright info 
#
# ******************************************************************************
#  Old changes (pre ade migration):
#    07/11/03 jrw  remove obsi references.
#    06/15/02 jrw  update copyright/IP notice.
#    12/03/01 gms  v3 mods.
#    01/03/99 jrw  update phraseology.
#    01/15/98 jrw  support obsi installation.
#    03/21/95 gms  fixed -y recognition.
#    11/28/94 gms  added trace.
#    10/13/94 gms  fixed status check from doinstall.sh
#    03/15/94 kcl  rb_tgt_tmp_room now set to -1 after every install.
#    03/02/94 gms  incorporate installhosu.sh inline.
#    09/08/92 gms  removed root check.
#    05/27/92 jrw  check to see whether invoker is root and, if not, complain.
#    05/25/92 jrw  support admin subset installation.
#    04/28/92 jrw  pass thru tape drives arg.
#
#  Usage:
#      install/installhost [client | server | admin | adminserver] host...

if (! $?OBTRACE) then
    echo "$argv" | grep "\-y" >&/dev/null
    if ( $status == 0 ) then
        setenv OBTRACE 1
    else
        setenv OBTRACE 0
        endif
    endif
if ($OBTRACE) then
    if (-f trenter) then
        trenter installhost $argv
    else if (-f install/trenter) then
        install/trenter installhost $argv
        endif
    endif

#  Common initialization:

if (! $?installobinit) then
    if (-f initinstall.sh) then
        source initinstall.sh
        set st = $status
    else if (-f install/initinstall.sh) then
        source install/initinstall.sh
        set st = $status
    else
        echo "ERROR: No initinstall.sh program exists in either '.' or './install'.  Can't continue."
        exit(1)
        endif
    if ($st) exit ($st)
    endif


#  Common UI parser:

source $idir/uiparse.sh
if ($?need_help) then
    set st = 0
usage:
    echo "usage:  install/installhost <installtype> <hostname>... [-a <admin-server>] [-f]"
    echo "    <installtype>   is one of 'admin', 'adminsub', 'server', or 'client'"
    echo "    <hostname>      is the name of the host to which you'd like to"
    echo "                    copy Oracle Secure Backup (in tar-file form)"
    echo "    <admin-server>  is the name of an administrative server that each named host"
    echo "                    is to use"
    echo "    [-f]            forces an update of each host's /etc/obconfig file"
    exit ($st)
    endif

if ( (! $?givenmode) || $?fail || ! $?other_args) then
    set st = 1
    goto usage
    endif


#  Setup drives argument to doinstall:

if ($?drives) then
    set drives_arg = "$drives"
else
    set drives_arg = ""
    endif


#  Cycle through the list of hosts and use doinstall.sh to do the
#  dirty work:

unset suppressed
set rval = 0
while ($#argv > 0)
    if ("$1" != "") then

        $idir/doinstall.sh $givenmode $argv[1] $drives_arg
        set ok = $status

	    setenv ob_tgt_tmp_room  "-1"

        if ($ok == 0) then
            :
        else if ($ok == 2) then
            set suppressed
        else if ($ok == 9) then
            exit (9)
        else 
            set rval = 1
            endif
        endif
    shift
    end

if ($rval == 0 && $?suppressed) set rval = 2
if ($OBTRACE) $idir/trexit installhost $rval
exit ($rval)

