source: MondoRescue/trunk/mondo/mondo/restore-scripts/mondo/compare-subroutine-me@ 1

Last change on this file since 1 was 1, checked in by bcornec, 19 years ago

Initial import from latest mondo-2.04_cvs_20050503/mindi-1.04_cvs_20050503 on http://www.mondorescue.org

File size: 2.4 KB
Line 
1#!/bin/sh
2
3LogIt "compare-subroutine-me --- starting"
4
5wildpath=""
6
7if [ "$#" -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
12fi
13
14archive=$1
15if [ "$#" -eq "2" ] ; then
16 wildpath=$2
17fi
18
19if [ ! -f "$archive" ] ; then
20 LogIt "Cannot find archive $archive" 1
21 exit 1
22fi
23
24# ---------------- compare a tarball --------------
25
26cd /mnt/RESTORING
27if [ "$?" -ne "0" ] ; then
28 LogIt "Cannot cd to /mnt/RESTORING" 1
29 exit 1
30fi
31
32
33if [ "`echo "$archive" | grep "\.bz2"`" != "" ]; then
34 callstr="-P bzip2 -Z"
35elif [ "`echo "$archive" | grep "\.lzo"`" != "" ] ; then
36 callstr="-P lzop -Z"
37elif [ "`echo "$archive" | grep "\.gz"`" != "" ]; then
38 callstr="-Z"
39elif [ "`echo "$archive" | grep "\.afio"`" != "" ]; then
40 callstr=""
41else
42 LogIt "Unknown filetype - $archive" 1
43 exit 1
44fi
45
46setno=`echo "$archive" | tr '/' '.' | tr '[:alpha:]' '.' --squeeze-repeats | cut -d'.' -f2`
47path=`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"
51if [ "$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
71else
72 afio -r -y $wildpath $callstr $archive &> /tmp/afio.log
73 res=$(($res+$?))
74fi
75if [ "`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;} \
79else {print $0;};};' | sort | uniq >> /tmp/afio.log.mashed
80 cat /tmp/afio.log.mashed
81 cat /tmp/afio.log.mashed >> /tmp/compare-me.log
82fi
83
84LogIt "compare-subroutine-me --- leaving"
85exit $res
Note: See TracBrowser for help on using the repository browser.