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
|
---|
64 | cat /tmp/mck.log
|
---|
65 | cat /tmp/mck.log >> /tmp/compare-me.log
|
---|
66 | else
|
---|
67 | LogIt "Unable to run mondo-checksum."
|
---|
68 | fi
|
---|
69 | fi
|
---|
70 | fi
|
---|
71 | else
|
---|
72 | afio -r -y $wildpath $callstr $archive &> /tmp/afio.log
|
---|
73 | res=$(($res+$?))
|
---|
74 | fi
|
---|
75 | if [ "`cat /tmp/afio.log`" != "" ] ; then
|
---|
76 | echo "Files reported by afio as changed:-" > /tmp/afio.log.mashed
|
---|
77 | cat /tmp/afio.log | sed s/'afio: "'/'|'/ | sed s/'": '/'|'/ \
|
---|
78 | | cut -d'|' -f2 | gawk '{ if (substr($0,1,1)!="/") {print"/"$0;} \
|
---|
79 | else {print $0;};};' | sort | uniq >> /tmp/afio.log.mashed
|
---|
80 | cat /tmp/afio.log.mashed
|
---|
81 | cat /tmp/afio.log.mashed >> /tmp/compare-me.log
|
---|
82 | fi
|
---|
83 |
|
---|
84 | LogIt "compare-subroutine-me --- leaving"
|
---|
85 | exit $res
|
---|