ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/Processing/bin/fixFile.sh
Revision: 1.1
Committed: Tue Feb 28 11:54:35 2012 UTC (13 years, 2 months ago) by paus
Content type: application/x-sh
Branch: MAIN
CVS Tags: Mit_029b, Mit_029, Mit_029_pre1, Mit_028a, Mit_028, Mit_027a, Mit_027, Mit_026, Mit_025e, Mit_025d
Log Message:
Last updates.

File Contents

# User Rev Content
1 paus 1.1 #!/bin/bash
2     #===================================================================================================
3     # Assume a local files is found to be broken. Go through a full recovery:
4     # + check they are really broken
5     # + check they are not broken on Tier-2
6     # + remove broken file from Tier-3 and download the proper one from Tier-2
7     # + in case also Tier-2 is broken check CERN and download even back to Tier-2
8     #===================================================================================================
9     MIT_LOC="/mnt/hadoop/cms/store/user/paus"
10     CERN_LOC="/castor/cern.ch/user/p/paus"
11    
12     FILE="$1"
13     FLAG="$2"
14    
15     fullFile="$FILE"
16     file=`basename $fullFile`
17     dir=`dirname $fullFile`
18     dset=`basename $dir`
19     tmp=`dirname $dir`
20     version=`basename $tmp`
21     tmp=`dirname $tmp`
22     cfg=`basename $tmp`
23    
24     test=`list $dir/$file 2> /dev/null`
25     if [ "$test" != "" ]
26     then
27     echo ""
28     echo " TEST - File exists, check integrity."
29     echo " $dir/$file"
30     test=`catalogFile.sh $dir $file 2> /dev/null | grep XX-CATALOG-XX`
31     if [ "$test" != "" ]
32     then
33     echo " STOP - File seems to be fine?! Leave it."
34     echo " $dir/$file"
35     echo ""
36     exit 0
37     else
38     echo " File is really broken. Remove it."
39     rm -f $dir/$file
40     fi
41     else
42     echo ""
43     echo " TEST - File does not exist."
44     echo " $dir/$file"
45     fi
46    
47     # once we arrive here, the file is gone and we are recovering
48    
49     echo " Start recovery from Tier-2."
50     test=`catalogFile.sh $MIT_LOC/$cfg/$version/$dset $file 2> /dev/null | grep XX-CATALOG-XX`
51     if [ "$test" != "" ]
52     then
53     echo ""
54     echo " GOOD - File seems to be fine on Tier-2. Grab it."
55     #echo "downloadFile.sh $MIT_LOC/$cfg/$version/$dset/$file $dir/$file"
56     downloadFile.sh $MIT_LOC/$cfg/$version/$dset/$file $dir/$file >& /dev/null
57     echo " -> Download status: $?"
58     test=`catalogFile.sh $dir $file 2> /dev/null | grep XX-CATALOG-XX`
59     if [ "$test" != "" ]
60     then
61     echo ""
62     echo " GOOD - Recovery completed successfully."
63     echo " $dir/$file"
64     echo ""
65     else
66     echo " ERRO - File is broken again. Removing it."
67     echo " $dir/$file"
68     echo ""
69     rm -f $dir/$file
70     fi
71     else
72     echo ""
73     echo " STOP - File seems to be broken on Tier-2."
74     # in case both Tier-2 and Tier-3 broken and requested removed both
75     if [ "$FLAG" == "remove" ]
76     then
77     remove --exe --catalog $dir/$file
78     remove --exe --catalog $MIT_LOC/$cfg/$version/$dset/$file
79     fi
80     echo " Start recovery from CERN."
81     test=`list $CERN_LOC/$cfg/$version/$dset/$file 2> /dev/null`
82     if [ "$test" != "" ]
83     then
84     echo ""
85     echo " GOOD - File seems to be available at CERN. Grab it."
86     downloadFile.sh $CERN_LOC/$cfg/$version/$dset/$file $dir/$file >& /dev/null
87     echo " -> Download status: $?"
88     test=`catalogFile.sh $dir $file 2> /dev/null | grep XX-CATALOG-XX`
89     if [ "$test" != "" ]
90     then
91     echo ""
92     echo " GOOD - Recovery completed successfully from CERN."
93     echo " $dir/$file"
94     # try to recover Tier-2 from CERN
95     echo " Start recovery on Tier-2."
96     downloadFile.sh $CERN_LOC/$cfg/$version/$dset/$file $MIT_LOC/$cfg/$version/$dset/$file \
97     >& /dev/null
98     echo " -> Download (to Tier-2) status: $?"
99     test=`catalogFile.sh $MIT_LOC/$cfg/$version/$dset $file 2> /dev/null | grep XX-CATALOG-XX`
100     if [ "$test" != "" ]
101     then
102     echo ""
103     echo " GOOD - Recovery on Tier-2 completed successfully from CERN."
104     echo " $MIT_LOC/$cfg/$version/$dset/$file"
105     echo ""
106     else
107     echo " ERRO - File on tier-2 is still broken. Stop process"
108     echo " $MIT_LOC/$cfg/$version/$dset/$file"
109     echo ""
110     fi
111     else
112     echo " ERRO - File is broken again. Removing it."
113     echo " $dir/$file"
114     echo ""
115     rm -f $dir/$file
116     fi
117     else
118     echo ""
119     echo " STOP - File seems not to be available at CERN."
120     echo ""
121     fi
122     fi
123    
124     exit 0