#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'cpdisk2tp.sh' <<'END_OF_FILE' X#! /bin/sh X: X# X# cpdisk2tp - copy a tape to disk files (for SunOS-4) X# X#ident "@(#)tapestuff:RELEASE-0_1:cpdisk2tp.sh,v 1.1 1995/03/29 03:44:51 woods Rel" X XPATH=/usr/5bin:/usr/bin:/usr/ucb ; export PATH XIFS=" X" ; export IFS X Xargv0="`basename $0`" X XUSAGE="Usage: $argv0 [-RVXdv] [-D destdir] [-n tapename] [-f tapedev]" X XHELP="$USAGE X -R retension the tape before starting X -V verify tape files have been written correctly X -X don't copy files (i.e. verify only) X -v be verbose about what's happening X -D srcd specify a directory from which to read the tape files X -n name use this as the filename prefix (default 'tape_file') X -f dev use this as the name of the tape device. X -d enable debug mode (doesn't offline the tape)." X XTAPENAME="tape_file" XTAPEDEV="/dev/rst8" # default to QIC-24 or QIC-150, first drive, high density XTAPEBS=126b # best read/write size for tape device XPIPEBS=4k # size of a pipe buffer in SunOS-4.1.x XNTAPEDEV="/dev/nrst8" X XRETENSION="false" XVERIFY="false" XDOCOPY="true" XVERBOSE="false" XDEBUG="false" XSRCDIR="" X Xwhile getopts "D:RVXdhvn:f:" OPTCHAR ; do X case $OPTCHAR in X D) X SRCDIR=$OPTARG X ;; X R) X RETENSION="true" X ;; X V) X VERIFY="true" X ;; X X) X DOCOPY="false" X ;; X d) X DEBUG="true" X ;; X n) X TAPENAME=$OPTARG X ;; X f) X TAPEDEV=$OPTARG X NTAPEDEV="`dirname $TAPEDEV`/n`basename $TAPEDEV`" X $VERBOSE && echo "No-rewind tape is $NTAPEDEV" X ;; X v) X VERBOSE=$OPTARG X ;; X h) X echo "$HELP" X exit 0 X ;; X \?) X echo "$USAGE" 1>&2 X exit 2 X ;; X esac Xdone Xshift `expr $OPTIND - 1` X Xif [ $# -ne 0 ] ; then X echo "$USAGE" 1>&2 X exit 2 Xfi X Xif [ -n "$SRCDIR" ] ; then X SRCDIR="$SRCDIR/" Xfi X Xif [ -n "$SRCDIR" -a ! -d "$SRCDIR" ] ; then X echo "$argv0: $SRCDIR: not a directory." 1>&2 X exit 1 Xfi X X$DEBUG && echo "Tape device is $TAPEDEV, no-rewind device is $NTAPEDEV." X Xif $RETENSION ; then X $VERBOSE && echo "Retensioning tape...\c" X mt -f $TAPEDEV retension X $VERBOSE && echo " Done." Xfi X X X$VERBOSE && echo "Rewinding tape...\c" Xmt -f $TAPEDEV rewind X$VERBOSE && echo " Done." X X$DEBUG || trap "rc=$?; echo 'Aborted... taking $TAPEDEV offline...\c'; mt -f $TAPEDEV offline; echo ' Done.'; exit $rc" 1 2 3 15 X Xif $DOCOPY ; then X # write files to tape X # X for FILENAME in ${SRCDIR}${TAPENAME}.[0-9][0-9][0-9][0-9] ; do X $VERBOSE && echo "Writing tape file $CURRFILE from $FILENAME..." X if dd bs=$TAPEBS of=$NTAPEDEV if=$FILENAME ; then X : X else X echo "$argv0: error from dd... quitting" 1>&2 X exit 1 X fi X done X $VERBOSE && echo "Rewinding tape...\c" X mt -f $TAPEDEV rewind X $VERBOSE && echo " Done." Xfi X Xif $VERIFY ; then X # verify files on tape -- assume this patter sorts them right X # X for FILENAME in ${SRCDIR}${TAPENAME}.[0-9][0-9][0-9][0-9] ; do X $VERBOSE && echo "Verifying tape file $CURRFILE with $FILENAME..." X if dd bs=$PIPEBS if=$NTAPEDEV | cmp - $FILENAME ; then X : X else X echo "$argv0: error from dd or cmp... quitting" 1>&2 X exit 1 X fi X done Xfi X X$DEBUG || { $VERBOSE && echo "Taking tape offline...\c" ; } X$DEBUG || mt -f $TAPEDEV offline X$DEBUG || { $VERBOSE && echo " Done." ; } X$DEBUG && { $VERBOSE && echo "Rewinding tape...\c" ; } X$DEBUG && mt -f $TAPEDEV rewind X$DEBUG && { $VERBOSE && echo " Done." ; } X Xexit 0 END_OF_FILE if test 3189 -ne `wc -c <'cpdisk2tp.sh'`; then echo shar: \"'cpdisk2tp.sh'\" unpacked with wrong size! fi # end of 'cpdisk2tp.sh' fi if test -f 'cptp2disk.sh' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'cptp2disk.sh'\" else echo shar: Extracting \"'cptp2disk.sh'\" \(4520 characters\) sed "s/^X//" >'cptp2disk.sh' <<'END_OF_FILE' X#! /bin/sh X: X# X# cptp2dsk - copy a tape to disk files (for SunOS-4) X# X#ident "@(#)tapestuff:RELEASE-0_1:cptp2disk.sh,v 1.2 1995/03/29 03:42:48 woods Rel" X XPATH=/usr/5bin:/usr/bin:/usr/ucb ; export PATH XIFS=" X" ; export IFS X Xargv0="`basename $0`" X XUSAGE="Usage: $argv0 [-CRVXdv] [-N #-files] [-D destdir] [-n tapename] [-f tapedev]" X XHELP="$USAGE X -C only count files, don't read them X -R retension the tape before starting X -V verify tape files have been saved correctly X -X don't copy files (i.e. verify only) X -v be verbose about what's happening X -D dest specify a directory in which to put the tape files X -N nfil specify the number of files known to be on the tape X -n name use this as the filename prefix (default 'tape_file') X -f dev use this as the name of the tape device. X -d enable debug mode (doesn't offline the tape)." X XTAPENAME="tape_file" XTAPEDEV="/dev/rst8" # default to QIC-24 or QIC-150, first drive, high density XTAPEBS=126b # best read/write size for tape device XPIPEBS=4k # size of a pipe buffer in SunOS-4.1.x XNTAPEDEV="/dev/nrst8" X XCOUNTONLY="false" XRETENSION="false" XVERIFY="false" XDOCOPY="true" XVERBOSE="false" XDEBUG="false" XDESTDIR="" XFILECOUNT=0 X Xwhile getopts "CD:RVXhvdN:n:f:" OPTCHAR ; do X case $OPTCHAR in X C) X COUNTONLY="true" X ;; X D) X DESTDIR=$OPTARG X ;; X N) X FILECOUNT=$OPTARG X if [ "$FILECOUNT" -le 0 ] ; then X echo "$argv0: -N arg must be >= 0" 1>&2 X echo "$USAGE" X exit 2 X fi X ;; X R) X RETENSION="true" X ;; X V) X VERIFY="true" X ;; X X) X DOCOPY="false" X ;; X d) X DEBUG="true" X ;; X n) X TAPENAME=$OPTARG X ;; X f) X TAPEDEV=$OPTARG X NTAPEDEV="`dirname $TAPEDEV`/n`basename $TAPEDEV`" X $VERBOSE && echo "No-rewind tape is $NTAPEDEV" X ;; X v) X VERBOSE=$OPTARG X ;; X h) X echo "$HELP" X exit 0 X ;; X \?) X echo "$USAGE" 1>&2 X exit 2 X ;; X esac Xdone Xshift `expr $OPTIND - 1` X Xif [ $# -ne 0 ] ; then X echo "$USAGE" 1>&2 X exit 2 Xfi X Xif [ -n "$DESTDIR" ] ; then X DESTDIR="$DESTDIR/" Xfi X Xif [ -n "$DESTDIR" -a ! -d "$DESTDIR" ] ; then X echo "$argv0: $DESTDIR: not a directory." 1>&2 X exit 1 Xfi X X$DEBUG && echo "Tape device is $TAPEDEV, no-rewind device is $NTAPEDEV." X Xif $RETENSION ; then X $VERBOSE && echo "Retensioning tape...\c" X mt -f $TAPEDEV retension X $VERBOSE && echo " Done." Xfi X X X$VERBOSE && echo "Rewinding tape...\c" Xmt -f $TAPEDEV rewind X$VERBOSE && echo " Done." X X$DEBUG || trap "rc=$?; echo 'Aborted... taking $TAPEDEV offline...\c'; mt -f $TAPEDEV offline; echo ' Done.'; exit $rc" 1 2 3 15 X Xif [ $FILECOUNT -eq 0 ] ; then X # count tape files X # X while : ; do X $VERBOSE && echo "Counting file # $FILECOUNT...\c" X if expr "`dd bs=$TAPEBS if=$NTAPEDEV of=/dev/null 2>&1`" : '0+0 records in' > /dev/null ; then X $VERBOSE && echo " Done, and found EOT." X break; X fi X FILECOUNT=`expr $FILECOUNT + 1` X $VERBOSE && echo " Done." X done X $VERBOSE && echo "Rewinding tape...\c" X mt -f $TAPEDEV rewind X $VERBOSE && echo " Done." Xfi X X$VERBOSE && echo "Found $FILECOUNT files on tape loaded in $TAPEDEV." X Xif $COUNTONLY ; then X $VERBOSE || echo "FILECOUNT" X $DEBUG || { $VERBOSE && echo "Taking tape offline...\c" ; } X $DEBUG || mt -f $TAPEDEV offline X $DEBUG || { $VERBOSE && echo " Done." ; } X $DEBUG && { $VERBOSE && echo "Rewinding tape...\c" ; } X $DEBUG && mt -f $TAPEDEV rewind X $DEBUG && { $VERBOSE && echo " Done." ; } X exit 0 Xfi X XCURRFILE=0 X Xif $DOCOPY ; then X # read files from tape X # X while [ $CURRFILE -lt $FILECOUNT ] ; do X FILENAME=`awk 'BEGIN {printf("%s%s.%04d\n", "'${DESTDIR}'", "'${TAPENAME}'", '$CURRFILE'); exit;}'` X $VERBOSE && echo "Reading tape file $CURRFILE into $FILENAME..." X if dd bs=$TAPEBS if=$NTAPEDEV of=$FILENAME ; then X CURRFILE=`expr $CURRFILE + 1` X else X echo "$argv0: error from dd... quitting" 1>&2 X exit 1 X fi X done X $VERBOSE && echo "Rewinding tape...\c" X mt -f $TAPEDEV rewind X $VERBOSE && echo " Done." Xfi X Xif $VERIFY ; then X CURRFILE=0 X while [ $CURRFILE -lt $FILECOUNT ] ; do X FILENAME=`awk 'BEGIN {printf("%s%s.%04d\n", "'${DESTDIR}'", "'${TAPENAME}'", '$CURRFILE'); exit;}'` X $VERBOSE && echo "Verifying tape file $CURRFILE with $FILENAME..." X if dd bs=$PIPEBS if=$NTAPEDEV | cmp - $FILENAME ; then X CURRFILE=`expr $CURRFILE + 1` X else X echo "$argv0: error from dd or cmp... quitting" 1>&2 X exit 1 X fi X done Xfi X X$DEBUG || { $VERBOSE && echo "Taking tape offline...\c" ; } X$DEBUG || mt -f $TAPEDEV offline X$DEBUG || { $VERBOSE && echo " Done." ; } X$DEBUG && { $VERBOSE && echo "Rewinding tape...\c" ; } X$DEBUG && mt -f $TAPEDEV rewind X$DEBUG && { $VERBOSE && echo " Done." ; } X Xexit 0 END_OF_FILE if test 4520 -ne `wc -c <'cptp2disk.sh'`; then echo shar: \"'cptp2disk.sh'\" unpacked with wrong size! fi # end of 'cptp2disk.sh' fi echo shar: End of shell archive. exit 0 .