home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / 3b1 / volume02 / tapeops / part04 < prev    next >
Encoding:
Internet Message Format  |  1993-03-08  |  12.7 KB

  1. Path: comp-sources-3b1
  2. From: vern@zebra.alphacdc.com (vern)
  3. Subject:  v02i038:  3B1 Tape processing utilities, Part04/04
  4. Newsgroups: comp.sources.3b1
  5. Approved: dave@galaxia.network23.com
  6. X-Checksum-Snefru: 1e6e8481 6e574ab6 0a0f2afa 226b3c2b
  7.  
  8. Submitted-by: vern@zebra.alphacdc.com (vern)
  9. Posting-number: Volume 2, Issue 38
  10. Archive-name: tapeops/part04
  11.  
  12. #! /bin/sh
  13. # This is a shell archive.  Remove anything before this line, then unpack
  14. # it by saving it into a file and typing "sh file".  To overwrite existing
  15. # files, type "sh file -c".  You can also feed this as standard input via
  16. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  17. # will see the following message at the end:
  18. #        "End of archive 4 (of 4)."
  19. # Contents:  MANIFEST save.list src/Makefile utils/fix-1.sh
  20. #   utils/panic.sh utils/recov.sh utils/rewind.sh utils/wrk.pl
  21. #   utils/zap.sh
  22. # Wrapped by vern@zebra on Mon Mar  8 08:57:48 1993
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. if test -f MANIFEST -a "${1}" != "-c" ; then 
  25.   echo shar: Will not over-write existing file \"MANIFEST\"
  26. else
  27. echo shar: Extracting \"MANIFEST\" \(1254 characters\)
  28. sed "s/^X//" >MANIFEST <<'END_OF_MANIFEST'
  29. X   File Name        Archive #    Description
  30. X-----------------------------------------------------------
  31. X Files                     1    
  32. X MANIFEST                  4    This shipping list
  33. X README                    1    
  34. X backup.sh                 2    
  35. X header.sh                 3    
  36. X link.list                 2    
  37. X mk.index.sh               3    
  38. X params                    3    
  39. X prep.sh                   3    
  40. X rd.tape.sh                3    
  41. X save.list                 4    
  42. X squirrel.sh               2    
  43. X src                       1    
  44. X src/Makefile              4    
  45. X src/fix.cpio.c            2    
  46. X src/group.c               3    
  47. X src/mini-z.c              2    
  48. X src/pick.files.c          1    
  49. X src/read.vtoc.c           3    
  50. X utils                     1    
  51. X utils/convert.sh          3    
  52. X utils/copy.sh             2    
  53. X utils/fix-1.sh            4    
  54. X utils/panic.pl            2    
  55. X utils/panic.sh            4    
  56. X utils/recov.sh            4    
  57. X utils/rewind.sh           4    
  58. X utils/set_up.sh           3    
  59. X utils/trim.pl             2    
  60. X utils/trim.sh             3    
  61. X utils/util.hdr.sh         3    
  62. X utils/util.prep.sh        3    
  63. X utils/util.rd.sh          3    
  64. X utils/util.sq.sh          3    
  65. X utils/wr.tape.sh          1    
  66. X utils/wrk.pl              4    
  67. X utils/zap.sh              4    
  68. X wr.tape.sh                1    
  69. END_OF_MANIFEST
  70. if test 1254 -ne `wc -c <MANIFEST`; then
  71.     echo shar: \"MANIFEST\" unpacked with wrong size!
  72. fi
  73. # end of overwriting check
  74. fi
  75. if test -f save.list -a "${1}" != "-c" ; then 
  76.   echo shar: Will not over-write existing file \"save.list\"
  77. else
  78. echo shar: Extracting \"save.list\" \(427 characters\)
  79. sed "s/^X//" >save.list <<'END_OF_save.list'
  80. X# This is the list of directories or files to be scanned
  81. X# for 'squirrel'ing to 'arcdir'.  Later, 'arcdir' is to be
  82. X# processed by 'prep.sh' for transfer to tape.
  83. X
  84. X/news/to.zebra        # This should be changed to your local name.
  85. X/news/to.tape
  86. X/news/comp/sys/att
  87. X/news/comp/sys/3b1
  88. X/news/comp/sources
  89. X/news/alt/sources
  90. X/news/sci/physics/fusion
  91. X
  92. X# The following entries may be needed for converting old tapes.
  93. X#/news/.tape.ops
  94. X#/tmp
  95. END_OF_save.list
  96. if test 427 -ne `wc -c <save.list`; then
  97.     echo shar: \"save.list\" unpacked with wrong size!
  98. fi
  99. # end of overwriting check
  100. fi
  101. if test -f src/Makefile -a "${1}" != "-c" ; then 
  102.   echo shar: Will not over-write existing file \"src/Makefile\"
  103. else
  104. echo shar: Extracting \"src/Makefile\" \(333 characters\)
  105. sed "s/^X//" >src/Makefile <<'END_OF_src/Makefile'
  106. XCFLAGS        = -O -v
  107. XLDFLAGS        = -s
  108. X
  109. XSHAREDLIB    = /lib/crt0s.o /lib/shlib.ifile
  110. X
  111. XTARGETS        = pick.files read.vtoc group fix.cpio mini-z
  112. X
  113. XOBJS        = $(TARGETS).o
  114. X
  115. Xall: $(TARGETS)
  116. X
  117. X$(TARGETS): $$@.o
  118. X    $(LD) $(LDFLAGS) $(SHAREDLIB) $? $(LIBS) -o $@
  119. X    @if [ "$@" = "mini-z" ]; then chmod 1755 $@; fi
  120. X    chgrp news $@
  121. X    chown netnews $@
  122. X
  123. Xclean:
  124. X    rm *.o;
  125. END_OF_src/Makefile
  126. if test 333 -ne `wc -c <src/Makefile`; then
  127.     echo shar: \"src/Makefile\" unpacked with wrong size!
  128. fi
  129. # end of overwriting check
  130. fi
  131. if test -f utils/fix-1.sh -a "${1}" != "-c" ; then 
  132.   echo shar: Will not over-write existing file \"utils/fix-1.sh\"
  133. else
  134. echo shar: Extracting \"utils/fix-1.sh\" \(823 characters\)
  135. sed "s/^X//" >utils/fix-1.sh <<'END_OF_utils/fix-1.sh'
  136. X# This is the sequence of operations to read articles from a tape
  137. X# prepared using 'prep' and 'wr.tape'.
  138. X
  139. Xif [ ! "$WRKDIR" ]
  140. Xthen
  141. X    . /news/.tape.ops/utils/util.hdr.sh
  142. Xfi
  143. X
  144. X# This should be the start of the program
  145. Xset `Tgetname -r | tr -d "'"`
  146. Xname=$1
  147. X
  148. Xecho `date +%T`" The contents of tape \"$name\" are:"
  149. X$SRCDIR/read.vtoc -w9 > xyz
  150. X
  151. Xfor i in 1 2 3 4 5 6 7 8 9
  152. Xdo
  153. X    while
  154. X        read line
  155. X    do
  156. X        set $line
  157. X        if [ "$1" = "$i" ]
  158. X        then
  159. X            CHAP=$1
  160. X            SSNAME=$2
  161. X            SSCMNT="$3 $4 $5 $6 $7"
  162. X            NFILES=$8
  163. X            OFFSET=$9
  164. X            shift
  165. X            NBLOCKS=$9
  166. X        fi
  167. X    done < xyz
  168. X
  169. X    echo "name = $name"
  170. X    echo "CHAP = $CHAP"
  171. X    echo "SSNAME = $SSNAME"
  172. X    echo "SSCMNT = $SSCMNT"
  173. X    echo "NFILES = $NFILES"
  174. X    echo "OFFSET = $OFFSET"
  175. X    echo "NBLOCKS = $NBLOCKS"
  176. X    Tgetname -w "Backup by Names" "$name" "$SSNAME" "$SSCMNT" \
  177. X        $OFFSET $NBLOCKS $NFILES
  178. Xdone
  179. Xrm -f xyz
  180. Xexit
  181. END_OF_utils/fix-1.sh
  182. if test 823 -ne `wc -c <utils/fix-1.sh`; then
  183.     echo shar: \"utils/fix-1.sh\" unpacked with wrong size!
  184. fi
  185. chmod +x utils/fix-1.sh
  186. # end of overwriting check
  187. fi
  188. if test -f utils/panic.sh -a "${1}" != "-c" ; then 
  189.   echo shar: Will not over-write existing file \"utils/panic.sh\"
  190. else
  191. echo shar: Extracting \"utils/panic.sh\" \(1204 characters\)
  192. sed "s/^X//" >utils/panic.sh <<'END_OF_utils/panic.sh'
  193. X
  194. X# The purpose of this script is to prepare the 'squirrel'ed files
  195. X# for transfer to tape.  This consists of building a 'contents'
  196. X# file from the "Subject" line in the posted articles.  The 'contents'
  197. X# is sorted and similar titles are moved together for easier reference.
  198. X# The articles are then compressed and moved to the 'savdir' where
  199. X# they can copied to tape.
  200. X
  201. Xexport NEWSDEV=/dev/fp002
  202. Xexport WRKDIR=/news/.tape.ops/utils
  203. Xexport CACHE=$WRKDIR/cache
  204. Xexport ARCDIR=$WRKDIR/arcdir
  205. Xexport RDPARMS=$WRKDIR/rd.params
  206. Xexport PARAMS=$WRKDIR/rd.params        # was "wr.params"
  207. Xexport SAVDIR=$WRKDIR/savdir
  208. Xexport CONFILE=$WRKDIR/contents
  209. Xexport SRCDIR=/news/.tape.ops/src
  210. Xexport PNTRS=$WRKDIR/pntrs
  211. Xexport CPNTRS=$WRKDIR/c.pntrs
  212. Xexport LIST=$WRKDIR/save.list        # Directory list to be saved
  213. Xexport LINKS=$WRKDIR/link.list
  214. Xexport KLINKS=$WRKDIR/wrk.links
  215. Xexport GOOFS=$WRKDIR/goofs
  216. Xexport TMP1=$WRKDIR/tmpp1
  217. Xexport TMP2=$WRKDIR/tmpp2
  218. Xexport COPY=1
  219. Xexport GRP=news
  220. Xexport OWN=netnews
  221. Xexport PERCENT=6200    # This is the last five percent of disk space
  222. Xexport MAXOFFSET=45384  # or B1FE 512 byte blocks = 23329792 bytes
  223. X# If we add 2 blocks for header, B200 512 byte blocks
  224. X# or 1DAA blocks per stream???
  225. X
  226. Xwr.tape.sh
  227. END_OF_utils/panic.sh
  228. if test 1204 -ne `wc -c <utils/panic.sh`; then
  229.     echo shar: \"utils/panic.sh\" unpacked with wrong size!
  230. fi
  231. chmod +x utils/panic.sh
  232. # end of overwriting check
  233. fi
  234. if test -f utils/recov.sh -a "${1}" != "-c" ; then 
  235.   echo shar: Will not over-write existing file \"utils/recov.sh\"
  236. else
  237. echo shar: Extracting \"utils/recov.sh\" \(932 characters\)
  238. sed "s/^X//" >utils/recov.sh <<'END_OF_utils/recov.sh'
  239. X# This is the sequence of operations to read articles from a tape
  240. X# prepared using 'copy.sh'.
  241. X
  242. Xif [ ! "$WRKDIR" ]
  243. Xthen
  244. X    . /news/.tape.ops/utils/util.hdr.sh
  245. Xfi
  246. X
  247. XTgetname -t 
  248. XTgetname -v
  249. X
  250. X# ARCDIR=$WRKDIR/arcdir
  251. Xchap=`sed -n 's/Next source chapter:\    //p' $RDPARMS`
  252. Xset `$SRCDIR/read.vtoc -r$chap`
  253. Xoffset=$2
  254. Xblocks=$3
  255. Xset `Tgetname -r | tr -d "'"`
  256. Xname=$1
  257. X
  258. Xecho "\tWe will be attempting to recover chapter '$chap', starting at
  259. X    offset '$offset' and will read '$blocks' blocks of the tape."
  260. X
  261. Xif [ -d $ARCDIR ]
  262. Xthen
  263. X    echo echo `date +%T`" Purging old '$ARCDIR'."
  264. X    rm -rf $ARCDIR
  265. Xfi
  266. Xmkdir $ARCDIR
  267. X
  268. Xcd $ARCDIR
  269. Xecho `date +%T`" Reading chapter $chap from tape '$name' starting \
  270. Xat $offset offset."
  271. Xdbuf -iT124"O"$offset"S"$blocks /dev/rft3 | $SRCDIR/fix.cpio -b$blocks -c$chap
  272. X
  273. Xrm -f contents ss.filelist
  274. X
  275. Xcd $WRKDIR
  276. X
  277. Xecho `date +%T`" You can remove the tape now."
  278. Xecho "\tCheck size of directories before proceding. <cr> \c"
  279. Xread ch
  280. Xexit
  281. END_OF_utils/recov.sh
  282. if test 932 -ne `wc -c <utils/recov.sh`; then
  283.     echo shar: \"utils/recov.sh\" unpacked with wrong size!
  284. fi
  285. chmod +x utils/recov.sh
  286. # end of overwriting check
  287. fi
  288. if test -f utils/rewind.sh -a "${1}" != "-c" ; then 
  289.   echo shar: Will not over-write existing file \"utils/rewind.sh\"
  290. else
  291. echo shar: Extracting \"utils/rewind.sh\" \(481 characters\)
  292. sed "s/^X//" >utils/rewind.sh <<'END_OF_utils/rewind.sh'
  293. Xstart=`date +%T`
  294. Xecho `date +%T`" Rewinding test procedure."
  295. XTgetname -v &
  296. Xrm -f /tmp/*
  297. Xrm -f BUfiles
  298. Xrm -f contents
  299. Xrm -f ss.filelist
  300. Xrm -f bk.*
  301. Xrm -f c.pntrs
  302. Xrm -rf cache arcdir
  303. Xecho `date +%T`" Copying hold to 'arcdir'."
  304. Xmkdir arcdir
  305. Xcp hold/[1-3]* arcdir
  306. Xcp hold/[4-]* arcdir
  307. Xmv savdir cache
  308. Xrm -f cache/contents cache/ss.filelist
  309. X
  310. Xecho `date +%T`" Running:"
  311. Xpanic.pl
  312. X../src/group contents
  313. Xpanic.sh
  314. Xtail -12 vch
  315. Xecho `date +%T`" Done again."
  316. Xecho "$start was the start time."
  317. X
  318. END_OF_utils/rewind.sh
  319. if test 481 -ne `wc -c <utils/rewind.sh`; then
  320.     echo shar: \"utils/rewind.sh\" unpacked with wrong size!
  321. fi
  322. chmod +x utils/rewind.sh
  323. # end of overwriting check
  324. fi
  325. if test -f utils/wrk.pl -a "${1}" != "-c" ; then 
  326.   echo shar: Will not over-write existing file \"utils/wrk.pl\"
  327. else
  328. echo shar: Extracting \"utils/wrk.pl\" \(857 characters\)
  329. sed "s/^X//" >utils/wrk.pl <<'END_OF_utils/wrk.pl'
  330. Xeval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}'
  331. X    if 0;
  332. X
  333. Xrequire 'flush.pl';
  334. X$CACHE = "cache";
  335. X$ARCDIR = "arcdir";
  336. X$SAVDIR = "savdir";
  337. X
  338. Xprint "Running:\n";
  339. Xopen( FRM, "ls -l $ARCDIR | cut -c27-37,51- | sort -nr |" );
  340. X$move = 1;
  341. Xwhile( <FRM> ) {
  342. X    chop;
  343. Xprint "In = >$_<\n";
  344. X    if ( $_ == 0 ) { last; }
  345. X    if ( $move ) {
  346. X        if ( $first ) {
  347. X#            print &ntime(time),
  348. X            print
  349. X                " Moving residual 'arcdir' to 'cache'.\n";
  350. X            $first = 0;
  351. X        }
  352. X        ($size, $fname) = split( ' ' );
  353. X        if ( $fname eq "" ) { next; }
  354. X        system( "mv $ARCDIR/$fname $CACHE/$$.$fname" );
  355. X#        print( "mv $ARCDIR/$fname $CACHE/$$.$fname\n" );
  356. X    }
  357. X    else {
  358. X        print &ntime(time)," Moving 'arcdir' to 'cache'.\n";
  359. X        print " Moving 'arcdir' to 'cache'.\n";
  360. X        system( "rm -fr cache; mv arcdir cache" );
  361. X#        print( "rm -fr cache; mv arcdir cache\n" );
  362. X        last;
  363. X    }
  364. X}
  365. Xprint "Last\n";
  366. X&flush( FRM );
  367. Xclose( FRM );
  368. END_OF_utils/wrk.pl
  369. if test 857 -ne `wc -c <utils/wrk.pl`; then
  370.     echo shar: \"utils/wrk.pl\" unpacked with wrong size!
  371. fi
  372. chmod +x utils/wrk.pl
  373. # end of overwriting check
  374. fi
  375. if test -f utils/zap.sh -a "${1}" != "-c" ; then 
  376.   echo shar: Will not over-write existing file \"utils/zap.sh\"
  377. else
  378. echo shar: Extracting \"utils/zap.sh\" \(982 characters\)
  379. sed "s/^X//" >utils/zap.sh <<'END_OF_utils/zap.sh'
  380. XSRCDIR=/news/.tape.ops/src
  381. XTgetname -t
  382. Xret=$?
  383. Xif [ $ret != 0 ]
  384. Xthen
  385. X    echo "Please insert a tape. Q)uit or <cr> to continue. \c"
  386. X    read  ch
  387. X    if [ "$ch" = "q" -o "$ch" = "Q" ]
  388. X    then
  389. X        exit 1
  390. X    fi
  391. Xfi
  392. Xset `Tgetname -b | tr -d "'"`
  393. Xret=$?
  394. Xname=$1
  395. Xtoffset=$2
  396. Xif [ $ret = 30 ]
  397. Xthen
  398. X    echo "\n\tThis tape has the \"SAFE\" key set.
  399. X\tPlease exchange it for a tape we can write onto.
  400. X\t    <cr> to continue."
  401. X    read -r ch
  402. X    exit 1
  403. Xfi
  404. Xecho `date +%T`" The contents of tape \"$name\" are:"
  405. X$SRCDIR/read.vtoc -w9
  406. Xecho "\tIs this the tape you wish to ZAP? \c"
  407. Xread ch
  408. Xif [ "$ch" = "y" -o "$ch" = "Y" ]
  409. Xthen
  410. X    Tgetname -w "Backup by Names" "Data-001" "" "" 0 0 0
  411. X#            "$BTYPE"       "$TPNAME" "$SSNAME" "$SSCMNT"
  412. X#               $OFFSET $NBLOCKS $NFILES
  413. X    ret=$?
  414. X    if [ "$ret" != "0" ]
  415. X    then
  416. X        echo "\tAn error has occurred while trying to update\
  417. X the data block.
  418. X\tError number = "$ret
  419. X        exit 1
  420. X    fi
  421. X    Tgetname -v
  422. X    echo `date +%T`" Zapping complete.  The new contents are:"
  423. X    $SRCDIR/read.vtoc -w9
  424. Xfi
  425. END_OF_utils/zap.sh
  426. if test 982 -ne `wc -c <utils/zap.sh`; then
  427.     echo shar: \"utils/zap.sh\" unpacked with wrong size!
  428. fi
  429. chmod +x utils/zap.sh
  430. # end of overwriting check
  431. fi
  432. echo shar: End of archive 4 \(of 4\).
  433. cp /dev/null ark4isdone
  434. MISSING=""
  435. for I in 1 2 3 4 ; do
  436.     if test ! -f ark${I}isdone ; then
  437.     MISSING="${MISSING} ${I}"
  438.     fi
  439. done
  440. if test "${MISSING}" = "" ; then
  441.     echo You have unpacked all 4 archives.
  442.     rm -f ark[1-9]isdone
  443. else
  444.     echo You still need to unpack the following archives:
  445.     echo "        " ${MISSING}
  446. fi
  447. ##  End of shell archive.
  448. exit 0
  449.  
  450. Vernon C. Hoxie                                {ncar,csn}!scicom!zebra!vern
  451. 3975 W. 29th Ave.                                   vern@zebra.alphacdc.COM
  452. Denver, Colo., 80212          voice: 303-477-1780        uucp: 303-455-2670
  453.  
  454. -- 
  455. David H. Brierley
  456. Home: dave@galaxia.network23.com; Work: dhb@quahog.ssd.ray.com
  457. Send comp.sources.3b1 submissions to comp-sources-3b1@galaxia.network23.com
  458. %% Pardon me Professor, can I be excused, my brain is full. **
  459.