source: trunk/MagicSoft/Mars/datacenter/scripts/checkmd5sum@ 9129

Last change on this file since 9129 was 9114, checked in by snruegam, 16 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.6 KB
Line 
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# The script will be automised by being executed after reading tapes with
33# the not-yet finished script readlapalmatapes. At the moment it is being
34# executed by hand.
35#
36
37echo "Please specify the tape number (e.g. 3MG005)."
38read no
39echo "Thank you. Your query is being processed. This may take some time."
40
41checkpath=/home/lapalma/tapecont/cont/muxdata/checksums
42file=/home/lapalma/tapecont/cont/muxdata/tape_${no}L*.md5
43L=`echo $file | cut -c49`
44id=${no}L${L}
45
46if [ ! -f $file ]
47then
48 echo "tape $file not found -> aborting"
49 exit
50fi
51
52if [ -f ${checkpath}/tape_${id}.md5.lapalma ] || [ -f ${checkpath}/tape_${id}.md5.wue ]
53then
54 echo "Output files already existing. Are you sure you wish to continue (yes/no)?"
55 read cont
56 if [ ! $cont == "yes" ]
57 then
58 echo "Aborting."
59 exit
60 fi
61fi
62
63date | tee ${checkpath}/tape_${id}.md5.lapalma | tee ${checkpath}/tape_${id}.md5.wue
64muxslog=`grep muxdata/20[01][0-9].*/20[01][0-9].*.raw $file | wc -l`
65
66# read the tapecont file line by line
67while read line
68do
69 muxchk=`echo $line | cut -d/ -f1`
70 type=`echo $line | sed -e 's/.*20[01][0-9]\{5\}_.*\(.raw\)/\1/' | cut -c 0-4`
71 # only check muxdata rawfiles, not cc-, caco- or drivelog-files
72 if [ "$muxchk" = "muxdata" ] && [ "$type" = ".raw" ]
73 then
74 sum=($line)
75
76 # check if the file has been extracted from tape; if not, don't write anything to the logfiles (so they can still be compared)
77 if [ ! -f /magic/datacenter/fromtape/${sum[0]} ] && [ ! -f /data/fromtape/${sum[0]} ]
78 then
79 echo "File ${sum[0]} does not exist."
80 continue
81 fi
82
83 # reformat the files and checksums correctly and compare them
84 echo "${sum[1]} ${sum[0]}" >> ${checkpath}/tape_${id}.md5.lapalma
85
86 if [ ! -f /magic/datacenter/fromtape/${sum[0]} ]
87 then
88 ssh -nx phoenix nice -n 19 /opt/csw/bin/gmd5sum /data/fromtape/${sum[0]} | sed -e 's/\/data\/fromtape\///' >> ${checkpath}/tape_${id}.md5.wue
89 else
90 ssh -nx phoenix nice -n 19 /opt/csw/bin/gmd5sum /magic/datacenter/fromtape/${sum[0]} | sed -e 's/\/magic\/datacenter\/fromtape\///' >> ${checkpath}/tape_${id}.md5.wue
91 #md5sum /magic/datacenter/fromtape/${sum[0]} | sed -e 's/\/magic\/datacenter\/fromtape\///' >> ${checkpath}/tape_${id}.md5.wue
92 fi
93 fi
94done < $file
95
96date | tee -a ${checkpath}/tape_${id}.md5.lapalma | tee -a ${checkpath}/tape_${id}.md5.wue
97
98if [ ! -f ${checkpath}/tape_${id}.md5.lapalma ] || [ ! -f ${checkpath}/tape_${id}.md5.wue ]
99then
100 echo "No output files written! Something went wrong... -> aborting"
101 exit
102fi
103
104echo "Wrote checksums to ${checkpath}/tape_${id}.md5.lapalma and ${checkpath}/tape_${id}.md5.wue. Comparing now."
105
106# check for differences in the checksums
107output=`diff ${checkpath}/tape_${id}.md5.lapalma ${checkpath}/tape_${id}.md5.wue`
108
109if [ "$output" = "" ]
110then
111 echo "All checksums are identical!"
112 muxschk=`grep muxdata/20[01][0-9].*/20[01][0-9].*.raw ${checkpath}/tape_${id}.md5.wue | wc -l`
113 if [ $muxslog == $muxschk ]
114 then
115 echo "Number of checked files matches. Launching movingrawfiles now. (to be included)" | tee -a ${checkpath}/tape_${id}.md5.lapalma | tee -a ${checkpath}/tape_${id}.md5.wue
116 else
117 echo "Number of checked files doesn't match number of extracted files. Something went wrong..." | tee -a ${checkpath}/tape_${id}.md5.lapalma | tee -a ${checkpath}/tape_${id}.md5.wue
118 fi
119else
120 echo -e "The files are not identical! diff found the following differences:\n$output"
121fi
122
123echo "program terminated."
Note: See TracBrowser for help on using the repository browser.