1 | #!/bin/bash
|
---|
2 | #
|
---|
3 | # ========================================================================
|
---|
4 | #
|
---|
5 | # *
|
---|
6 | # * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
7 | # * Software. It is distributed to you in the hope that it can be a useful
|
---|
8 | # * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
9 | # * It is distributed WITHOUT ANY WARRANTY.
|
---|
10 | # *
|
---|
11 | # * Permission to use, copy, modify and distribute this software and its
|
---|
12 | # * documentation for any purpose is hereby granted without fee,
|
---|
13 | # * provided that the above copyright notice appear in all copies and
|
---|
14 | # * that both that copyright notice and this permission notice appear
|
---|
15 | # * in supporting documentation. It is provided "as is" without express
|
---|
16 | # * or implied warranty.
|
---|
17 | # *
|
---|
18 | #
|
---|
19 | #
|
---|
20 | # Author(s): Stefan Ruegamer 05/2007 <mailto:snruegam@astro.uni-wuerzburg.de>
|
---|
21 | #
|
---|
22 | # Copyright: MAGIC Software Development, 2000-2008
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | # This script is checking the md5 sums of files read from tape. It
|
---|
28 | # computes the checksums for the extracted files and compares them with
|
---|
29 | # the checksums from La Palma, read out from the md5 sum file which is
|
---|
30 | # transferred together with the logfile.
|
---|
31 | #
|
---|
32 |
|
---|
33 | no=$@
|
---|
34 | if [ "$no" == "" ]
|
---|
35 | then
|
---|
36 | echo "no tape specified -> aborting"
|
---|
37 | exit
|
---|
38 | fi
|
---|
39 |
|
---|
40 | checkpath=/home/lapalma/tapecont/cont/muxdata/checksums
|
---|
41 | file=/home/lapalma/tapecont/cont/muxdata/tape_${no}L*.md5
|
---|
42 | L=`echo $file | cut -c49`
|
---|
43 | id=${no}L${L}
|
---|
44 | logfile=${checkpath}/tape_${id}.log
|
---|
45 |
|
---|
46 | if [ ! -f $file ]
|
---|
47 | then
|
---|
48 | echo "tape $file not found -> aborting" >> $logfile 2>&1
|
---|
49 | exit
|
---|
50 | fi
|
---|
51 |
|
---|
52 | if [ -f ${checkpath}/tape_${id}.md5.lapalma ] || [ -f ${checkpath}/tape_${id}.md5.wue ]
|
---|
53 | then
|
---|
54 | echo "Output files already existing -> aborting" >> $logfile 2>&1
|
---|
55 | exit
|
---|
56 | # echo "Output files already existing. Are you sure you wish to continue (yes/no)?"
|
---|
57 | # read cont
|
---|
58 | # if [ ! $cont == "yes" ]
|
---|
59 | # then
|
---|
60 | # echo "Aborting."
|
---|
61 | # exit
|
---|
62 | # fi
|
---|
63 | fi
|
---|
64 |
|
---|
65 | if [ "`cat $file`" == "" ]
|
---|
66 | then
|
---|
67 | echo "$file is empty, the checksums are missing -> aborting" >> $logfile 2>&1
|
---|
68 | exit
|
---|
69 | fi
|
---|
70 |
|
---|
71 | date | tee ${checkpath}/tape_${id}.md5.lapalma | tee ${checkpath}/tape_${id}.md5.wue > /dev/null
|
---|
72 | muxslog=`grep muxdata/20[01][0-9].*/20[01][0-9].*.raw $file | wc -l`
|
---|
73 |
|
---|
74 | # read the tapecont file line by line
|
---|
75 | while read line
|
---|
76 | do
|
---|
77 | muxchk=`echo $line | cut -d/ -f1`
|
---|
78 | type=`echo $line | sed -e 's/.*20[01][0-9]\{5\}_.*\(.raw\)/\1/' | cut -c 0-4`
|
---|
79 | # only check muxdata rawfiles, not cc-, caco- or drivelog-files
|
---|
80 | if [ "$muxchk" = "muxdata" ] && [ "$type" = ".raw" ]
|
---|
81 | then
|
---|
82 | sum=($line)
|
---|
83 |
|
---|
84 | # check if the file has been extracted from tape; if not, don't write anything to the logfiles (so they can still be compared)
|
---|
85 | if [ ! -f /magic/datacenter/fromtape/${sum[0]} ] && [ ! -f /data/fromtape/${sum[0]} ]
|
---|
86 | then
|
---|
87 | echo "File ${sum[0]} does not exist." >> $logfile 2>&1
|
---|
88 | continue
|
---|
89 | fi
|
---|
90 |
|
---|
91 | # reformat the files and checksums correctly and compare them
|
---|
92 | echo "${sum[1]} ${sum[0]}" >> ${checkpath}/tape_${id}.md5.lapalma
|
---|
93 |
|
---|
94 | if [ ! -f /magic/datacenter/fromtape/${sum[0]} ]
|
---|
95 | then
|
---|
96 | nice -n 19 /opt/csw/bin/gmd5sum /data/fromtape/${sum[0]} | sed -e 's/\/data\/fromtape\///' >> ${checkpath}/tape_${id}.md5.wue
|
---|
97 | else
|
---|
98 | nice -n 19 /opt/csw/bin/gmd5sum /magic/datacenter/fromtape/${sum[0]} | sed -e 's/\/magic\/datacenter\/fromtape\///' >> ${checkpath}/tape_${id}.md5.wue
|
---|
99 | fi
|
---|
100 | fi
|
---|
101 | done < $file
|
---|
102 |
|
---|
103 | date | tee -a ${checkpath}/tape_${id}.md5.lapalma | tee -a ${checkpath}/tape_${id}.md5.wue > /dev/null
|
---|
104 |
|
---|
105 | if [ ! -f ${checkpath}/tape_${id}.md5.lapalma ] || [ ! -f ${checkpath}/tape_${id}.md5.wue ]
|
---|
106 | then
|
---|
107 | echo "No output files written! Something went wrong... -> aborting" >> $logfile 2>&1
|
---|
108 | exit
|
---|
109 | fi
|
---|
110 |
|
---|
111 | echo "Wrote checksums to ${checkpath}/tape_${id}.md5.lapalma and ${checkpath}/tape_${id}.md5.wue. Comparing now." >> $logfile 2>&1
|
---|
112 |
|
---|
113 | # check for differences in the checksums
|
---|
114 | output=`diff ${checkpath}/tape_${id}.md5.lapalma ${checkpath}/tape_${id}.md5.wue`
|
---|
115 |
|
---|
116 | if [ "$output" = "" ]
|
---|
117 | then
|
---|
118 | echo "All checksums are identical." >> $logfile 2>&1
|
---|
119 | muxschk=`grep muxdata/20[01][0-9].*/20[01][0-9].*.raw ${checkpath}/tape_${id}.md5.wue | wc -l`
|
---|
120 | if [ $muxslog == $muxschk ]
|
---|
121 | then
|
---|
122 | echo "Number of checked files matches. Files are ready." >> $logfile 2>&1
|
---|
123 | else
|
---|
124 | echo "Number of checked files doesn't match number of extracted files. Something went wrong..." >> $logfile 2>&1
|
---|
125 | fi
|
---|
126 | else
|
---|
127 | echo -e "The files are not identical! diff found the following differences:\n$output" >> $logfile 2>&1
|
---|
128 | fi
|
---|
129 |
|
---|
130 | echo "Program terminated." >> $logfile 2>&1
|
---|