#!/usr/bin/sh # Information Supplied by HBA Packager. PTFNAME=ptf2004 PTFLABEL="PTF2004: AMD PCI SCSI Host Adapter Driver\n Beta Release for UnixWare(r) 2\n Version 1.0\n" HBA525FD=1 # 1 - image can be placed onto a 5.25" 1.2MB floppy. # 0 - image CANNOT be placed onto a 5.25" 1.2MB floppy. HBA35FD=1 # 1 - image can be placed onto a 3.5" 720KB floppy. # 0 - image CANNOT be placed onto a 3.5" 720KB floppy. # HBA Shell Script starts here. CMD=$0 msghandler () { case "$1" in fmtmsg) echo "\n\nFloppy format in progress:" ;; hbadone) echo "\n\nHBA floppy created successfully!\n\nPlease remove the floppy from $desc and label as:" echo "\n$PTFLABEL\n\n" ;; hbamsg) echo "\n\nCopying HBA image onto the floppy:" ;; media) echo "Please insert a blank writable $fdsize floppy into $desc" echo "Press to continue: \c" ;; media_bad) echo "\n\nFAILURE: Bad media, try again with different media\n" exit 1 ;; media_error) echo "\n\nERROR: Floppy not present in drive\n\n" ;; mkfsmsg) echo "\n\nCreating file system on $fdsize floppy:" ;; mountpt) echo "FAILURE: Could not create temporary HBA mount point\n" exit 1 ;; nofd) echo "FAILURE: Cannot determine floppy device\n" exit 1 ;; start) echo "\nCreation of HBA Floppy Started:" echo "\n$PTFLABEL\n" ;; tarfile) echo "FAILURE: PTF tar file not found, $2\n" exit 1 ;; root) echo "FAILURE: Must be 'root'\n" exit 1 ;; usage) echo "Usage: $CMD 'PTF-tar-filename'" exit 1 esac } unmountfd () { umount $mountpt exit 1 } chgmountpt () { if [ -d /mnt ] then mountpt=/mnt mount 2>/dev/null | grep /mnt >/dev/null 2>&1 || return 0 fi mountpt=/tmp/hba mkdir $mountpt || msghandler mountpt return 0 } # Arg1 is floppy driver number. floppytype () { check_devs -f$1 case $? in 1) # 5.25" 360KB return 1 ;; 2) # 5.25" 1.2MB if [ $HBA525FD -eq 1 ] then fdsize=1.2MB fd=diskette$1 return 0 fi return 1 ;; 3) # 3.5" 720KB if [ $HBA35FD -eq 1 ] then fdsize=720KB fd=diskette$1 return 0 fi return 1 ;; 4) # 3.5" 1.44MB fdsize=1.44MB fd=diskette$1 return 0 ;; 5|6) # 3.5" 2.88MB - type is not standardized fdsize=2.88MB fd=diskette$1 return 0 ;; esac return 1 } # Are the 'root' user? id 2>/dev/null | grep root >/dev/null 2>&1 || msghandler root # Is tar file valid? if [ $# -ne 1 ] then msghandler usage fi tfile=$1 if [ ! -f $tfile ] then n_tfile=${tfile}.Z if [ ! -f $n_tfile ] then msghandler tarfile $tfile fi tfile=$n_tfile fi expr $tfile : '.*\(\.Z\)$' >/dev/null 2>&1 if [ $? -eq 0 ] then tcmd="zcat `pwd`/$tfile" else tcmd="cat `pwd`/$tfile" fi # Find a valid floppy drive that can be used to create the HBA. floppytype 1 || floppytype 2 || msghandler nofd # Get various info about the floppy devattr -v $fd desc fmtcmd mkfscmd bdevice mountpt capacity >/tmp/$$ || exit 1 . /tmp/$$ rm -f /tmp/$$ # Does mount point directory exist and avaibable for use? if [ ! -d $mountpt ] then chgmountpt else mount 2>/dev/null | grep $mountpt >/dev/null 2>&1 && chgmountpt fi # Display start message. msghandler start # Is floppy in the drive? while [ 1 ] do msghandler media read ans check_devs -g $bdevice && break msghandler media_error done # Format the floppy. msghandler fmtmsg $fmtcmd || msghandler media_bad # Make a filesystem on the media. msghandler mkfsmsg $mkfscmd || msghandler media_bad # Mount the floppy. msghandler hbamsg mount -F s5 $bdevice $mountpt || exit 1 # Create HBA floppy image. cwd=`pwd` cd $mountpt || unmountfd rm -rf lost+found $tcmd | tar -xovf - || unmountfd cd $PTFNAME mv * .. cd .. rmdir $PTFNAME cd $cwd # Unmount the floppy. umount $mountpt || exit 1 msghandler hbadone exit 0