#!/bin/ksh
#
# mkboottape.sh
#
# Shell script to create a bootable tape with no data. To be used for
# system maintenance only.
#
# John Roebuck - 02/12/99

if [ $# -ne 1 ]
   then echo " "
        echo "Usage : $0 tape-drive (eg rmt0 no /dev in front)"
        echo " "
        exit 1
fi

valid_tape=`lsdev -Cc tape | grep $1 | cut -d" " -f2`

if [ $valid_tape = "Available" ]
then

old_blocksize=`lsattr -El $1 | grep block_size | cut -d" " -f2`
old_blocksize=`expr $old_blocksize + 0`

if [ $old_blocksize != 512 ]
then
        chdev -l $1 -a block_size=512
fi

tctl -f  /dev/$1 rewind

bosboot -ad /dev/$1.1
mkinsttape /dev/$1.1

if [ old_blocksize != 512 ]
then
        chdev -l $1 -a block_size=$old_blocksize
fi

tctl -f  /dev/$1 rewind

else

echo "$1 is not a valid tape drive"

fi