#!/bin/ksh #h scotar - version 1.7 #h Extracts files from a multi-volume tar created on SCO Xenix/Unix #h onto Linux or other non-SCO platforms. #h #h usage: scotar [ help | ] #h defaults to /dev/fd0 #h #h Run scotar, put the first floppy in the drive and press [enter]. #h Put subsequent floppies in when prompted. #h When scotar asks for a volume number that is higher than your final one, #h leave the drive _empty_ and press [enter] one last time. #h #h Notes: #h - The original time-stamps are lost on any files that span volumes. This is #h possible to fix at some point by using stat and touch. #h - Screws up if you don't follow the prompt directions exactly. (you can #h always just re-run if you think you made a mistake.) #h #h history: #h 1.0 initial release, tested, works, requires bash-2.x #h 1.1 untested, port to ksh for portability #h 1.2 untested, added help (using "scripthelp"), #h removed "how many volumes" prompt #h 1.3 untested, greatly simplified, probable bug fix, commented code #h 1.4 *tested!*, changed wording of prompt to try and avoid reading last #h disk more than once. fixed minor help bug. #h hopefully the goal of portability is realised now. #h 1.5 fixed problem with absolute paths. #h 1.6 removed some pointless file-shuffling #h 1.7 added comments #h added more and better debug output #h attempt sco behviour with extracting absolute paths #h #h Brian K. White - brian@aljex.com - Aljex Software - July 28 2001 case $1 in h|-h|help|--help) scripthelp $0 ;exit ;; "") d=/dev/fd0 ;; *) d=$1 ;; esac # "true" or "false" - enable or disable verbose operation DEBUG=true echo "+--------------------------------------------------------------+" echo "| scotar - version 1.7 brian@aljex.com |" echo "| Extracts SCO Xenix/Unix multi-volume tars on linux/bsd/other |" echo "+--------------------------------------------------------------+" FINISHED=false ; c=1 ; U=ScoTarSav while true ; do # read-in a volume (extract all the files and remember their names) echo "\aInsert volume $c or remove final volume, and hit Enter: \c" ; read X dd if=$d of=/dev/null bs=1 count=1 >/dev/null 2>&1 && { echo "Reading volume $c ...\c" # V=`tar xvf $d |sed "s,^/,, ;s,\ /,\ ,g"` V=`tar xspPvf $d ` echo "done" } || { FINISHED=true } # if this is not the first volume, then look for file fragments to assemble [ $c -gt 1 ] && { [ -f $F ] && { # if a file exists now with same name as last file in previous volume, # then both files are fragments and need to be concatenated together. $DEBUG && echo "Reassembling file: $F" cat $F >>$F.$U } || { # if not, then the last file in the previous volume was not a fragment # and it should just be renamed back to it's original name. $DEBUG && echo "$F was not a fragment" } mv -f $F.$U $F } # if this was the final volume in the set, exit now $FINISHED && { echo "Done" ; exit ; } # rename the last file from this volume in case it is a fragment for F in $V ; do : ; done $DEBUG && echo "Saving possible fragment: $F" mv -f $F $F.$U # increment counter and proceed to next volume c=$((c+1)) done