#!/bin/bash # # Make md5sums for /all/ the files in the archive. # This way even if the archive as a whole is changed, or if various # indices are added or removed, we can be sure of the content of # each individual file. # Print a dot after each NUM md5sums NUM=50 if [ $# -ne 2 ] then echo "" echo "Usage: $0 " echo "" echo "directory: directory containing the Diebold memos" echo "outfile: name of the file to save all the md5sums" echo "" exit fi MD5SUM=`which md5sum` if [ "x$MD5SUM" == "x" ] then echo "No md5sum program found" fi FIND=`which find` if [ "x$FIND" == "x" ] then echo "No find program found" fi SORT=`which sort` if [ "x$SORT" == "x" ] then echo "No sort program found" fi if [ ! -d $1 ] then echo "No such archive directory: $1" exit fi if [ -f $2 ] then echo "Backing up old copy of $2." mv $2 ${2}.bak fi echo "Starting md5sums. Will store in $2. This may take a while." echo "Each '.' represents $NUM md5sums." c=0 for f in `$FIND $1 | $SORT ` do if [ -f $f ] then $MD5SUM $f >> $2 c=$((c+1)) r=$((c%${NUM})) if [ $c -gt 0 -a $r -eq 0 ] then echo -n "." fi fi done echo "" echo "Done."