[1] | 1 | #!/bin/sh
|
---|
| 2 |
|
---|
| 3 | LogIt "compare-subroutine-me --- starting"
|
---|
| 4 |
|
---|
| 5 | wildpath=""
|
---|
| 6 |
|
---|
| 7 | if [ "$#" -ne "2" ] && [ "$#" -ne "1" ] ; then
|
---|
| 8 | LogIt "compare-subroutine-me <archive> (<wildpath>)" 1
|
---|
| 9 | LogIt "e.g. compare-subroutine-me archives/15.afio.bz2" 1
|
---|
| 10 | Logit "or compare-subroutine-me archives/15.afio.bz2 /mnt/dos/*" 1
|
---|
| 11 | exit 1
|
---|
| 12 | fi
|
---|
| 13 |
|
---|
| 14 | archive=$1
|
---|
| 15 | if [ "$#" -eq "2" ] ; then
|
---|
| 16 | wildpath=$2
|
---|
| 17 | fi
|
---|
| 18 |
|
---|
| 19 | if [ ! -f "$archive" ] ; then
|
---|
| 20 | LogIt "Cannot find archive $archive" 1
|
---|
| 21 | exit 1
|
---|
| 22 | fi
|
---|
| 23 |
|
---|
| 24 | # ---------------- compare a tarball --------------
|
---|
| 25 |
|
---|
| 26 | cd /mnt/RESTORING
|
---|
| 27 | if [ "$?" -ne "0" ] ; then
|
---|
| 28 | LogIt "Cannot cd to /mnt/RESTORING" 1
|
---|
| 29 | exit 1
|
---|
| 30 | fi
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 | if [ "`echo "$archive" | grep "\.bz2"`" != "" ]; then
|
---|
| 34 | callstr="-P bzip2 -Z"
|
---|
| 35 | elif [ "`echo "$archive" | grep "\.lzo"`" != "" ] ; then
|
---|
| 36 | callstr="-P lzop -Z"
|
---|
| 37 | elif [ "`echo "$archive" | grep "\.gz"`" != "" ]; then
|
---|
| 38 | callstr="-Z"
|
---|
| 39 | elif [ "`echo "$archive" | grep "\.afio"`" != "" ]; then
|
---|
| 40 | callstr=""
|
---|
| 41 | else
|
---|
| 42 | LogIt "Unknown filetype - $archive" 1
|
---|
| 43 | exit 1
|
---|
| 44 | fi
|
---|
| 45 |
|
---|
| 46 | setno=`echo "$archive" | tr '/' '.' | tr '[:alpha:]' '.' --squeeze-repeats | cut -d'.' -f2`
|
---|
| 47 | path=`echo "$archive" | gawk '{i=split($0,res,"/");j=1;while(j<i){printf res[j]"/";j++;};}'`
|
---|
| 48 | #echo "archive = $archive"
|
---|
| 49 | #echo "path = $path"
|
---|
| 50 | #echo "setno = $setno"
|
---|
| 51 | if [ "$wildpath" = "" ] ; then
|
---|
| 52 | # ----verify----
|
---|
| 53 | afio -r $callstr $archive 2> /tmp/afio.log
|
---|
| 54 | res=$?
|
---|
| 55 | # afio -t $callstr $archive > /tmp/rsm.lst.tmp
|
---|
| 56 | if [ -s "$path/cklist.$setno" ] ; then
|
---|
| 57 | # ----md5sum----
|
---|
| 58 | mondo-checksum $path/filelist.$setno $path/cklist.$setno /mnt/RESTORING --verify &> /tmp/mck.log
|
---|
| 59 | r=$?
|
---|
| 60 | res=$(($res+$r))
|
---|
| 61 | if [ "$r" -ne "0" ] ; then
|
---|
| 62 | if [ "`cat /tmp/mck.log`" != "" ] ; then
|
---|
| 63 | echo "Files which, according to md5sum, have changed:-" >> /tmp/compare-me.log
|
---|
[277] | 64 | cat /tmp/mck.log | tee -a /tmp/compare-me.log
|
---|
[1] | 65 | else
|
---|
| 66 | LogIt "Unable to run mondo-checksum."
|
---|
| 67 | fi
|
---|
| 68 | fi
|
---|
| 69 | fi
|
---|
| 70 | else
|
---|
| 71 | afio -r -y $wildpath $callstr $archive &> /tmp/afio.log
|
---|
| 72 | res=$(($res+$?))
|
---|
| 73 | fi
|
---|
| 74 | if [ "`cat /tmp/afio.log`" != "" ] ; then
|
---|
| 75 | echo "Files reported by afio as changed:-" > /tmp/afio.log.mashed
|
---|
[277] | 76 | sed s/'afio: "'/'|'/ /tmp/afio.log | sed s/'": '/'|'/ \
|
---|
[1] | 77 | | cut -d'|' -f2 | gawk '{ if (substr($0,1,1)!="/") {print"/"$0;} \
|
---|
[277] | 78 | else {print $0;};};' | sort -u >> /tmp/afio.log.mashed
|
---|
| 79 | cat /tmp/afio.log.mashed | tee -a /tmp/compare-me.log
|
---|
[1] | 80 | fi
|
---|
| 81 |
|
---|
| 82 | LogIt "compare-subroutine-me --- leaving"
|
---|
| 83 | exit $res
|
---|