#!/bin/csh -f
#
# Copyright (c) 1992, 2005, Oracle. All rights reserved.  
#
#   NAME
#     prefer_rmt
#
#   DESCRIPTION
#     adjust PdAt so the rmt driver will be selected for 7208 or 8200 drives
#
#   MODIFIED   (MM/DD/YY) 
#   tdziedzi   05/20/05 - Product name change 
#   tdziedzi   05/18/04 - Executables name change 
#   tdziedzi   03/05/04 - Update vendor/product name, copyright info 
#
# ******************************************************************************
#  Old changes (pre ade migration):
#     06/15/02 jrw  update copyright/IP notice.

#   This script is used to arrange things so that the native (rmt)
#   driver is given control of an IBM 7208 tape drive during boot.
#   Here's the problem: after you install the Oracle Secure Backup
#   device driver, there are two entries in the PdAt database for
#   drives whose inquiry info reports "EXB-8200", viz:
#
#           % odmget -q"deflt='EXB-8200        '" PdAt
#           
#           PdAt:
#                   uniquetype = "tape/scsi/8mm"
#                   attribute = "model_name"
#                   deflt = "EXB-8200        "
#                   values = ""
#                   width = ""
#                   type = "R"
#                   generic = ""
#                   rep = "s"
#                   nls_index = 0
#           
#           PdAt:
#                   uniquetype = "tape/scsi/obt"
#                   attribute = "model_name"
#                   deflt = "EXB-8200        "
#                   values = ""
#                   width = ""
#                   type = "R"
#                   generic = ""
#                   rep = "s"
#                   nls_index = 0
#
#   The driver that is given control of such drives depends on the order
#   in which these two PdAt entries appear in the database. This script
#   ensures that the native (rmt) entry appears first, and therefore
#   that the rmt driver will gain control of the drive(s). There is a
#   a corresponding script -- install/prefer_ob -- that you can run
#   should you wish the Oracle Secure Backup driver to be given 
#   control of the drive(s) at boot time.
#
############################################################
#
#   look for -x (echo) option right away...

    echo $argv | grep -e "-x" >&/dev/null
    if ( $status == 0 ) set echo

############################################################
#
#   Make sure we've got the correct machine type...

    set os = `uname`
    if ($status) then
        echo "ERROR: uname failed -- cannot determine machine architecture."
        exit (1)
        endif

    if ($os != "AIX") then
        echo "ERROR: this script is intended to run only under AIX."
        exit (1)
        endif

############################################################
#
#   must be root...
    
    whoami |& grep root >&/dev/null
    if ($status) then
        id |& grep "uid=0" >&/dev/null
        if ($status) then
            echo "You must be logged in as 'root' to run this script.  Please"
            echo "change your user identity to 'root' and re-run this script."
            exit (1)
            endif
        endif

############################################################
#
#   retrieve, delete, and re-add entries for 8200 model_name attibutes...

odmget -q"uniquetype='tape/scsi/8mm' AND deflt='EXB-8200        '" PdAt >/tmp/rmt.8200
if ($status) then
    echo "odmget of tape/scsi/8mm failed"
    exit (1)
    endif
odmget -q"uniquetype='tape/scsi/ob' AND deflt='EXB-8200        '" PdAt >/tmp/ob.8200
if ($status) then
    echo "odmget of tape/scsi/ob failed"
    exit (1)
    endif
odmdelete -o PdAt -q"uniquetype='tape/scsi/8mm' AND deflt='EXB-8200        '"
odmdelete -o PdAt -q"uniquetype='tape/scsi/ob' AND deflt='EXB-8200        '"
odmadd /tmp/rmt.8200
odmadd /tmp/ob.8200


if ($?echo) odmget -q"deflt='EXB-8200        '" PdAt
