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

Last change on this file since 278 was 278, checked in by bcornec, 14 years ago

merge -r276:277 $SVN_M/branches/2.06

  • Property svn:keywords set to Id
File size: 2.3 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 | tee -a /tmp/compare-me.log
65        else
66        LogIt "Unable to run mondo-checksum."
67        fi
68    fi
69    fi
70else
71    afio -r -y $wildpath $callstr $archive &> /tmp/afio.log
72    res=$(($res+$?))
73fi
74if [ "`cat /tmp/afio.log`" != "" ] ; then
75    echo "Files reported by afio as changed:-" > /tmp/afio.log.mashed
76    sed s/'afio: "'/'|'/ /tmp/afio.log | sed s/'": '/'|'/ \
77| cut -d'|' -f2 | gawk '{ if (substr($0,1,1)!="/") {print"/"$0;} \
78else {print $0;};};' | sort -u >> /tmp/afio.log.mashed
79    cat /tmp/afio.log.mashed | tee -a /tmp/compare-me.log
80fi
81
82LogIt "compare-subroutine-me --- leaving"
83exit $res
Note: See TracBrowser for help on using the repository browser.