CE-cms-dummy 9.2 KB
Newer Older
Stefano Belforte's avatar
Stefano Belforte committed
1
#!/bin/sh
Stefano Belforte's avatar
Stefano Belforte committed
2
3

echo "<h2>Preliminary checks</h2>"
4
echo "<pre>"
Stefano Belforte's avatar
Stefano Belforte committed
5
set -x
6
7
8
9
uname -a
date
voms-proxy-info -identity -fqan
id
Stefano Belforte's avatar
Stefano Belforte committed
10
set +x
11
echo "version 1-7 12:45"
12
13
echo "</pre>"

Stefano Belforte's avatar
Stefano Belforte committed
14
15
16
17
info=0
warn=0
err=0

Stefano Belforte's avatar
Stefano Belforte committed
18
echo "<h2>Checking software directory for CMS VO</h2>"
Stefano Belforte's avatar
Stefano Belforte committed
19
if [ -n "$VO_CMS_SW_DIR" ] ; then
Stefano Belforte's avatar
Stefano Belforte committed
20
21
    SW_DIR=$VO_CMS_SW_DIR
    echo "Checking variable: \$VO_CMS_SW_DIR=$VO_CMS_SW_DIR"
Stefano Belforte's avatar
Stefano Belforte committed
22
23
24
25
elif [ -n "$OSG_APP" ] ; then
    SW_DIR=$OSG_APP/cmssoft/cms
    [ -f $OSG_GRID/setup.sh ] && source $OSG_GRID/setup.sh
    echo "Checking variable: \$OSG_APP/cmssoft/cms=$OSG_APP/cmssoft/cms"
Stefano Belforte's avatar
Stefano Belforte committed
26
27
else
    echo "ERROR: Neither VO_CMS_SW_DIR nor OSG_APP defined"
Stefano Belforte's avatar
Stefano Belforte committed
28
    echo "summary: SW_DIR_UNDEF"
Stefano Belforte's avatar
Stefano Belforte committed
29
30
31
    exit $SAME_ERROR
fi
echo "<pre>"
Stefano Belforte's avatar
Stefano Belforte committed
32
set -x
Stefano Belforte's avatar
Stefano Belforte committed
33
34
ls -ld $SW_DIR
result=$?
Stefano Belforte's avatar
Stefano Belforte committed
35
set +x
Stefano Belforte's avatar
Stefano Belforte committed
36
37
38
39
40
41
echo "</pre>"
echo

if [ $result != 0 ]
    then
    echo "ERROR: software directory non existent or non readable"
Stefano Belforte's avatar
Stefano Belforte committed
42
    echo "summary: NO_SW_DIR"
Stefano Belforte's avatar
Stefano Belforte committed
43
44
    exit $SAME_ERROR
fi
45

Stefano Belforte's avatar
Stefano Belforte committed
46
echo "<h2>Sourcing the CMS environment</h2>"
Stefano Belforte's avatar
Stefano Belforte committed
47
export SCRAM_ARCH=slc4_ia32_gcc345
48
echo "<pre>"
Stefano Belforte's avatar
Stefano Belforte committed
49
50
51
52
set -x
source $SW_DIR/cmsset_default.sh
result=$?
set +x
53
echo "</pre>"
Stefano Belforte's avatar
Stefano Belforte committed
54
55
56
echo

if [ $result != 0 ]
Stefano Belforte's avatar
Stefano Belforte committed
57
    then
Stefano Belforte's avatar
Stefano Belforte committed
58
59
60
    echo "ERROR: Could not find the CMS software initialisation script"
    echo "summary: NO_SETUP_SCRIPT"
    exit $SAME_ERROR
Stefano Belforte's avatar
Stefano Belforte committed
61
fi
62

Stefano Belforte's avatar
Stefano Belforte committed
63
64
echo "<h2>Make sure configuration directory is there</h2>"
echo "Checking variable: \$CMS_PATH=$CMS_PATH"
Stefano Belforte's avatar
Stefano Belforte committed
65
echo "<p>"
Stefano Belforte's avatar
Stefano Belforte committed
66
if [ -z $CMS_PATH ]; then
Stefano Belforte's avatar
Stefano Belforte committed
67
68
69
    echo "ERROR: CMS_PATH not defined"
    echo "summary: CMS_PATH_UNDEF"
    exit $SAME_ERROR
Stefano Belforte's avatar
Stefano Belforte committed
70
fi
71

Stefano Belforte's avatar
Stefano Belforte committed
72
if [ ! -d $CMS_PATH ] ; then
Stefano Belforte's avatar
Stefano Belforte committed
73
74
75
76
77
78
79
80
81
    echo "ERROR: CMS_PATH directory $CMS_PATH not existing"
    echo "summary: NO_CMS_PATH"
    exit $SAME_ERROR
fi

if [ ! -d $CMS_PATH/SITECONF/local/JobConfig ] ; then
    echo "ERROR: JobConfig directory $CMS_PATH/local/SITECONF/JobConfig not existing"
    echo "summary: NO_JOBCONFIG_DIR"
    exit $SAME_ERROR
Stefano Belforte's avatar
Stefano Belforte committed
82
fi
Stefano Belforte's avatar
Stefano Belforte committed
83

Stefano Belforte's avatar
Stefano Belforte committed
84
85
echo "<p>"
echo "OK"
Stefano Belforte's avatar
Stefano Belforte committed
86

Stefano Belforte's avatar
Stefano Belforte committed
87
88
89
90
91
92
93
94
95
96
echo "<h2>Make sure configuration file exists</h2>"

ConfigFile=${CMS_PATH}/SITECONF/local/JobConfig/site-local-config.xml
echo "Configuration file: $ConfigFile"
echo "<p>"

if [ ! -f $ConfigFile ] ; then
    echo "ERROR: Local Configuration file site-local-config.xml not existing"
    echo "summary: NO_SITELOCALCONFIG"
    exit $SAME_ERROR
97
fi
Stefano Belforte's avatar
Stefano Belforte committed
98
99
echo "<p>"
echo "OK"
Stefano Belforte's avatar
Stefano Belforte committed
100
echo "dump of Local Configuration file is <a href=\"#CfgDump\">here</a>"
Stefano Belforte's avatar
Stefano Belforte committed
101

Stefano Belforte's avatar
Stefano Belforte committed
102
103
echo "<h2>Make sure local configuration file has entries for TriviaFileCatalog,
local stage, site name and Squid</h2>"
Stefano Belforte's avatar
Stefano Belforte committed
104

Stefano Belforte's avatar
Stefano Belforte committed
105
106
107
108
109
110
111
grep -q "trivialcatalog" $ConfigFile
status=$?
if [ $status != 0 ] ; then
    echo "ERROR: TrivialFileCatlog string missing"
    error="summary: NO_TFC"
    err=1
fi
112

Stefano Belforte's avatar
Stefano Belforte committed
113
114
115
116
117
118
119
grep -q "local-stage-out" $ConfigFile
status=$?
if [ $status != 0 ] ; then
    echo "ERROR: LocalStageOut string missing"
    error="summary: NO_LOCALSTAGEOUT"
    err=1
fi
Stefano Belforte's avatar
Stefano Belforte committed
120

Stefano Belforte's avatar
Stefano Belforte committed
121
122
123
124
125
126
127
grep -q "site name" $ConfigFile
status=$?
if [ $status != 0 ] ; then
    echo "ERROR: site name string missing"
    error="summary: NO_SiteName"
    err=1
fi
Stefano Belforte's avatar
Stefano Belforte committed
128

Stefano Belforte's avatar
Stefano Belforte committed
129
130
131
132
133
134
grep -q "frontier-connect" $ConfigFile
status=$?
if [ $status != 0 ] ; then
    echo "ERROR: Frontier Configuration string missing"
    error="summary: NO_FRONTIER_CONFIG"
    err=1
135
fi
Stefano Belforte's avatar
Stefano Belforte committed
136

Stefano Belforte's avatar
Stefano Belforte committed
137
if [ $err == 0 ] ; then
Stefano Belforte's avatar
Stefano Belforte committed
138
139
 echo "<p>"
 echo "OK"
140
fi
Stefano Belforte's avatar
Stefano Belforte committed
141

Stefano Belforte's avatar
Stefano Belforte committed
142
143
144
145
146
147
148
149
150
151
152
echo "<p>"

echo "<h2>Make sure TFC file is where config file says it should be</h2>"
TFCfile=`grep "trivialcatalog" $ConfigFile | cut -d':' -f2| cut -d'?' -f1|head -1`
echo "Checking file: $TFCfile"

if [ ! -f $TFCFile ] ; then
    echo "ERROR: TrivialFileCatalg $TFCfile not existing"
    error="summary: NO_TFC file"
    err=1
fi
Stefano Belforte's avatar
Stefano Belforte committed
153
154
155
#if [ $err == 1 ] ; then
#    exit $SAME_ERROR
#fi
Stefano Belforte's avatar
Stefano Belforte committed
156
157
158
159
160

echo "<p>"
echo "OK"
echo "<p>"

Stefano Belforte's avatar
Stefano Belforte committed
161
if [ $err == 1 ] ; then
Stefano Belforte's avatar
Stefano Belforte committed
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
    echo "ERROR: invalid local configuration file $ConfigFile"
    echo $error
fi

echo "<h2>Compare local configuration file and TFC with CVS</h2>"

siteName=`grep "site name" $ConfigFile | grep -v "subsite name" | cut -d'"' -f2`
echo "siteName =" $siteName
subSiteName=`grep "subsite name" $ConfigFile | cut -d'"' -f2`
_subSiteName=
if [ "x$subSiteName" == "x" ] ; then
   echo "subSiteName =" $subSiteName
else
   echo "subSiteName =" $subSiteName
   _subSiteName=_`echo $subSiteName`
fi
echo "<br>"
179

Stefano Belforte's avatar
Stefano Belforte committed
180
181
182
183
184
asCvs=1
cvsUrl="\"http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/COMP/SITECONF/${siteName}/JobConfig/site-local-config${_subSiteName}.xml?rev=HEAD&content-type=text/plain\""
outFile="/tmp/site-local-config-from-CVS.xml"
echo "Fetch CVS copy of local config from $cvsUrl<br>"
./fetch-from-web $cvsUrl $outFile
185
rc=$?
Stefano Belforte's avatar
Stefano Belforte committed
186
187
188
189
echo "rc = " $rc
#echo " Execute: wget -nv -r -t 1 -T 300 \"http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/COMP/SITECONF/${siteName}/JobConfig/site-local-config${_subSiteName}.xml?rev=HEAD&content-type=text/plain\" --output-document=/tmp/site-local-config-from-CVS.xml"
#wget -nv -r -t 1 -T 300 "http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/COMP/SITECONF/${siteName}/JobConfig/site-local-config${_subSiteName}.xml?rev=HEAD&content-type=text/plain" --output-document=/tmp/site-local-config-from-CVS.xml

190
191
echo "<pre">
set -x
192
[ $rc == $SAME_INFO ] && info=1
193
[ $rc == $SAME_WARNING ] && warn=1
194

Stefano Belforte's avatar
Stefano Belforte committed
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
if [ $rc == $SAME_WARNING ] || [$rc == $SAME_ERROR ] ; then
  echo "<br>INFO: failed to access CVS Web repository<bre>"
else
  diff -q -w -B $ConfigFile /tmp/site-local-config-from-CVS.xml
  if [ $? == 1 ] ; then asCvs=0; fi
  echo "<br>"
  if [ $asCvs == 0 ] ; then
    warn=1
    echo "WARNING: local site configuration file differ from CVS"
    diff $ConfigFile /tmp/site-local-config-from-CVS.xml > /tmp/diflist
    echo "<pre>"
    cat /tmp/diflist | sed 's/</\&lt;/g' | sed 's/>/\&gt;/g'
    echo "</pre>"
    rm -f /tmp/diflist
  else
    echo "OK local site configuration file agrees with CVS copy"
    echo "<br>"
  fi
  rm -f /tmp/site-local-config-from-CVS.xml
fi

216
217
218
set +x
echo "</pre">

Stefano Belforte's avatar
Stefano Belforte committed
219
asCvs=1
220
cvsUrl="\"http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/COMP/SITECONF/${siteName}/PhEDEx/storage.xml?rev=HEAD&content-type=text/plain\""
Stefano Belforte's avatar
Stefano Belforte committed
221
222
223
224
225
226
227
228
outFile="/tmp/storage-from-CVS.xml"
echo "Fetch CVS copy of TFC from $cvsUrl"
./fetch-from-web $cvsUrl $outFile
rc=$?
echo "rc = " $rc
#echo "Execute: wget -nv -r -t 1 -T 300 \"http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/COMP/SITECONF/${siteName}/PhEDEx/storage.xml?rev=HEAD&content-type=text/plain\" --output-document=/tmp/storage-from-CVS.xml"
#wget -nv -r -t 1 -T 300 "http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/COMP/SITECONF/${siteName}/PhEDEx/storage.xml?rev=HEAD&content-type=text/plain" --output-document=/tmp/storage-from-CVS.xml
#rc=$?
229
230
231

echo "<pre">
set -x
Stefano Belforte's avatar
Stefano Belforte committed
232
[ $rc == $SAME_INFO ] && info=1
233
[ $rc == $SAME_WARNING ] && warn=1
Stefano Belforte's avatar
cleanup    
Stefano Belforte committed
234

Stefano Belforte's avatar
Stefano Belforte committed
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
if [ $rc == $SAME_WARNING ] || [$rc == $SAME_ERROR ] ; then
  echo "<br>INFO: failed to access CVS Web repository<bre>"
else
  diff -q -w -B $TFCfile /tmp/storage-from-CVS.xml
  if [ $? == 1 ] ; then asCvs=0; fi
  echo "<br>"
  if [ $asCvs == 0 ] ; then
    warn=1
    echo "WARNING: local Trivial Catalog File file differ from CVS"
    diff $TFCfile /tmp/storage-from-CVS.xml > /tmp/diflist
    echo "<pre>"
    cat /tmp/diflist | sed 's/</\&lt;/g' | sed 's/>/\&gt;/g'
    echo "</pre>"
    rm -f /tmp/diflist
  else
    echo "OK local Trivial File Catalog file agrees with CVS copy"
    echo "<br>"
  fi
  rm -f /tmp/storage-from-CVS.xml
254
fi
Stefano Belforte's avatar
Stefano Belforte committed
255

256
257
258
set +x
echo "</pre">

Stefano Belforte's avatar
Stefano Belforte committed
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
echo "dump of TFC file is <a href=\"#TFCDump\">here</a>"


echo "<p>"


echo "<h2>Verify presence of commands needed for remote stageout</h2>"
echo "Needs at least ( lcg_utils 1.6.7 and gfal 1.10.8 ) or ( srmcp 2.0 ) " 

echo "<p>"
echo "<pre>"
stageOutError=1

which lcg-cp
rc=$?
if [ $rc == 0 ] ; then
  lcg-cp --version
  lcgVersion=`lcg-cp --version|grep "lcg_util"|cut -d'-' -f2`
  gfalVersion=`lcg-cp --version|grep GFAL|cut -d'-' -f3`
  lcgV1=`echo $lcgVersion|cut -d. -f1`
  lcgV2=`echo $lcgVersion|cut -d. -f2`
  lcgV3=`echo $lcgVersion|cut -d. -f3`
  gfalV1=`echo $gfalVersion|cut -d. -f1`
  gfalV2=`echo $gfalVersion|cut -d. -f2`
  gfalV3=`echo $gfalVersion|cut -d. -f3`
  lcgOK=0
  if [ $lcgV1 -gt 1 ] ; then
    lcgOK=1
  else
    if [ $lcgV1 -eq 1 ] && [ $lcgV2 -gt 6 ] ; then
      lcgOK=1
    else
      if [ $lcgV2 -eq 6 ] && [ $lcgV3 -ge 7 ] ; then
	lcgOK=1
      fi
294
    fi
295
  fi
Stefano Belforte's avatar
Stefano Belforte committed
296
297
298
299
300
301
302
303
304
  gfalOK=0
  if [ $gfalV1 -gt 1 ] ; then
    gfalOK=1
  else
    if [ $gfalV1 -eq 1 ] && [ $gfalV2 -gt 10 ] ; then
      gfalOK=1
    else
      if [ $gfalV2 -eq 10 ] && [ $gfalV3 -ge 8 ] ; then
	 gfalOK=1
305
      fi
Stefano Belforte's avatar
Stefano Belforte committed
306
    fi
Stefano Belforte's avatar
Stefano Belforte committed
307
  fi
Stefano Belforte's avatar
Stefano Belforte committed
308

Stefano Belforte's avatar
Stefano Belforte committed
309
310
311
  if [ $lcgOK == 1 ] ; then
      if [ $gfalOK == 1 ] ; then
	  stageOutError=0
312
      fi
Stefano Belforte's avatar
Stefano Belforte committed
313
  fi
Stefano Belforte's avatar
Stefano Belforte committed
314
315
fi

Stefano Belforte's avatar
Stefano Belforte committed
316
echo "</pre><p><pre>"
Stefano Belforte's avatar
Stefano Belforte committed
317

Stefano Belforte's avatar
Stefano Belforte committed
318
319
which srmcp
rc=$?
Stefano Belforte's avatar
Stefano Belforte committed
320

Stefano Belforte's avatar
Stefano Belforte committed
321
322
323
324
325
326
327
328
329
if [ $rc == 0 ] ; then
  srmcp -version | grep -v WARNING
  srmcpVersion=`srmcp -version 2>&1 |egrep "Client version"\|"implementation version"|cut -d' ' -f8`
  srmcpV1=`echo $srmcpVersion|cut -d. -f1`
  srmcpV2=`echo $srmcpVersion|cut -d. -f2`
#  srmcpV3=`echo $srmcpVersion|cut -d. -f3`
  if [ $srmcpV1 -ge 2 ] ; then
      stageOutError=0
  fi
Stefano Belforte's avatar
Stefano Belforte committed
330
331
fi

Stefano Belforte's avatar
cleanup    
Stefano Belforte committed
332

Stefano Belforte's avatar
Stefano Belforte committed
333
334
335
336
337
338
echo "</pre>"
if [ $stageOutError == 1  ] ; then
    echo "ERROR: No validated command for remote stageout available"
    err=1
else
    echo "OK"
Stefano Belforte's avatar
Stefano Belforte committed
339
fi
Stefano Belforte's avatar
Stefano Belforte committed
340
echo "<p>"
Stefano Belforte's avatar
Stefano Belforte committed
341

342

Stefano Belforte's avatar
Stefano Belforte committed
343
344


Stefano Belforte's avatar
Stefano Belforte committed
345
346
347
echo "<p>"
echo "<hr>"
echo "<p>"
Stefano Belforte's avatar
Stefano Belforte committed
348

Stefano Belforte's avatar
Stefano Belforte committed
349

Stefano Belforte's avatar
Stefano Belforte committed
350
351
352
353
354
355
356
357
358
359
360
echo "<h2>Dump of local configuration files</h2><br>"

echo "<h3><a name="CfgDump"></a>Configuration File Dump</h3><pre>"
cat $ConfigFile  | sed 's/</\&lt;/g' | sed 's/>/\&gt;/g'
echo "</pre>"

echo "<h3><a name="TFCDump"></a>TFC file Dump</h3><pre>"
cat $TFCfile  | sed 's/</\&lt;/g' | sed 's/>/\&gt;/g'
echo "</pre>"


Stefano Belforte's avatar
Stefano Belforte committed
361
if [ $err == 1 ] ; then
Stefano Belforte's avatar
Stefano Belforte committed
362
    exit $SAME_ERROR
Stefano Belforte's avatar
Stefano Belforte committed
363
364
fi

Stefano Belforte's avatar
Stefano Belforte committed
365
366
if [ $warn == 1 ] ; then
    exit $SAME_WARNING
367
368
fi

Stefano Belforte's avatar
Stefano Belforte committed
369
370
371
if [ $info == 1 ] ; then
    exit $SAME_INFO
fi
372

373
exit $SAME_OK