-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfunctions-cms-cvmfs-mgmt
6996 lines (6469 loc) · 339 KB
/
functions-cms-cvmfs-mgmt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
####### BEGIN Functions 12345
WORKDIR=/cvmfs/cms.cern.ch
export VO_CMS_SW_DIR=$WORKDIR
workdir=$HOME
updated_list=/cvmfs/cms.cern.ch/cvmfs-cms.cern.ch-updates
#rsync_source="$HOME/eos2/cms/store/group/phys_generator/cvmfs/gridpacks"
#rsync_name="/cvmfs/cms.cern.ch/phys_generator/gridpacks"
rsync_destination="/cvmfs/cms.cern.ch/phys_generator/gridpacks"
bootstrap_script=http://cmsrep.cern.ch/cmssw/repos/bootstrap.sh # 01FEB2017
# Release Map
releases_map="https://cmssdt.cern.ch/SDT/releases.map"
releases_map_local=/home/cvcms/releases.map
dev_arch_cmssws=/home/cvcms/cron_install_cmssw.dev.arch.cmssws.txt
dev_arch_rpm_list=/home/cvcms/cron_install_cmssw.dev.arch.rpm
# Filter for ARCHs and CMSSWs
archs_excluded="_ia32_"
cmssws_excluded="CMSSW_4_2_8_SLHCstd_patch1 CMSSW_4_1_3_patch1 CMSSW_4_2_0 CMSSW_4_2_0_pre6 CMSSW_4_2_2_SLHC_pre1 CMSSW_4_2_3_SLHC_pre1 CMSSW_4_2_8_SLHC1_patch1 MSSW_4_2_8_SLHCstd_patch1 CMSSW_4_3_0_pre7 CMSSW_4_4_2_p10JEmalloc CMSSW_5_0_0_g4emtest CMSSW_5_0_0_pre5_root532rc1 CMSSW_4_2_3_onlpatch2 CMSSW_4_2_3_onlpatch4 CMSSW_4_2_7_hinpatch1 CMSSW_4_2_7_onlpatch2 CMSSW_4_2_9_HLT2_onlpatch1 CMSSW_4_4_2_onlpatch1 CMSSW_5_1_0_pre1 CMSSW_5_1_0_pre2 CMSSW_5_2_0_pre2_TS113282 CMSSW_5_2_0_pre3HLT CMSSW_5_3_4_TS125616patch1 CMSSW_5_3_X CMSSW_6_2_X CMSSW_6_2_X_SLHC CMSSW_7_0_X CMSSW_7_1_X CMSSW_7_2_X CMSSW_7_3_X CMSSW_7_4_X CMSSW_7_1_50 CMSSW_10_1_X CMSSW_9_4_MAOD_X CMSSW_9_4_AN_X CMSSW_10_2_X"
cvmfs_server_yes=yes
cvmfs_server_name=$(grep cvmfs_server_name= $HOME/cron_install_cmssw.config | grep -v \# | cut -d= -f2)
rpmdb_local_dir=$(grep rpmdb_local_dir= $HOME/cron_install_cmssw.config | grep -v \# | cut -d= -f2)
notifytowhom=$(grep notifytowhom= $HOME/cron_install_cmssw.config | grep -v \# | cut -d= -f2)
theuser=$(/usr/bin/whoami)
jenkins_cmssw=$(grep ^jenkins_cmssw= $HOME/cron_install_cmssw.config | grep -v \# | cut -d= -f2)
lhapdf_update=$(grep ^lhapdf_update= $HOME/cron_install_cmssw.config | grep -v \# | cut -d= -f2)
cvmfs_server_name=$(eval echo $cvmfs_server_name)
[ "$(/bin/hostname -f)" == "x$cvmfs_server_name" ] || cvmfs_server_yes=no
# This machine
which_slc=slc7
# DOCKER TAGS
DOCKER_TAG=cmssw/cc7:amd64
DOCKER_TAG_SLC6=cmssw/slc6:amd64
DOCKER_TAG_SLC8=cmssw/cc8:amd64
# Functions
function check_if_cvmfs_server_in_transaction () {
what=$1
cvmfs_server list | grep stratum0 | grep -q transaction
if [ $? -eq 0 ] ; then
printf "$what stratum0 in transaction. See \n$(cvmfs_server list)\nThis is strange\n" | mail -s "$what stratum0 in transaction" $notifytowhom
echo ERROR cvmfs server already in transaction
return 1
fi
return 0
}
function cvmfs_server_transaction_and_check_status () {
what=$1
cvmfs_server transaction
status=$?
if [ $? -eq 0 ] ; then
echo INFO transaction OK for $what
return 0
else
echo ERROR transaction check FAILED
printf "$what: cvmfs_server_transaction_and_check_status Failed for $what\n" | mail -s "ERROR: cvmfs_server_transaction_and_check_status Failed" $notifytowhom
return 1
fi
}
function generate_reasonable_lhapdf_version_number () {
what=$1
lhapdfset_versions=$2
lhapdf_web=$3
LHAPDFSET_VERSION_NEW=
if [ -f $lhapdfset_versions ] ; then
projectnumber=$(echo $(wget -q -O- $lhapdf_web |grep "<span id=\"projectnumber\">" | cut -d\< -f2 | cut -d\> -f2))
if [ "x$projectnumber" == "x" ] ; then
printf "ERROR generate_lhapdf_version_number projectnumber is empty\nCheck if $lhapdf_web has the projectnumber for $what\n" | mail -s "ERROR: generate_lhapdf_version_number projectnumber is empty" $notifytowhom
return 1
fi
if [ "x$(echo $projectnumber | sed 's#\.##g' | sed 's#[0-9]##g')" != "x" ] ; then
printf "ERROR generate_lhapdf_version_number projectnumber=$projectnumber has non-number\nCheck the projectnumber from $lhapdf_web has for $what\n" | mail -s "ERROR: generate_lhapdf_version_number projectnumber has non-number" $notifytowhom
return 1
fi
grep -q $projectnumber $lhapdfset_versions
if [ $? -eq 0 ] ; then
LHAPDFSET_VERSION_LAST=$(grep $projectnumber $lhapdfset_versions | tail -1)
LAST_CHAR=$(echo $LHAPDFSET_VERSION_LAST | sed "s#$projectnumber##")
LAST_CHAR=${LAST_CHAR: -1}
if [ "x$LAST_CHAR" == "xz" ] ; then
LHAPDFSET_VERSION_NEW=${LHAPDFSET_VERSION_LAST}a
else
alphavar=( {a..z} )
NEW_LAST_CHAR=$(for ((x=0; x<26; x++)); do echo ${alphavar[x]} ; done | grep -A 1 ${LAST_CHAR} | tail -1)
LHAPDFSET_VERSION_NEW=${LHAPDFSET_VERSION_LAST:0:$((${#LHAPDFSET_VERSION_LAST}-1))}${NEW_LAST_CHAR}
fi
else
majora=$(echo $projectnumber | cut -d. -f1) ; [ "X$majora" == "X" ] && majora=0
minora=$(echo $projectnumber | cut -d. -f2) ; [ "X$minora" == "X" ] && minora=0
subva=$(echo $projectnumber | cut -d. -f3) ; [ "X$subva" == "X" ] && subva=0
majorb=$(echo $(tail -1 $lhapdfset_versions | sed 's#[a-z]##g') | cut -d. -f1) ; [ "X$majorb" == "X" ] && majorb=0
minorb=$(echo $(tail -1 $lhapdfset_versions | sed 's#[a-z]##g') | cut -d. -f2) ; [ "X$minorb" == "X" ] && minorb=0
subvb=$(echo $(tail -1 $lhapdfset_versions | sed 's#[a-z]##g') | cut -d. -f3) ; [ "X$subvb" == "X" ] && subvb=0
if [ ${majora}${minora}${subva} -le ${majorb}${minorb}${subvb} ] ; then
printf "ERROR generate_lhapdf_version_number ${majora}${minora}${subva} -le ${majorb}${minorb}${subvb}\nCheck the projectnumber from $lhapdf_web has for $what\nAnd $(tail -1 $lhapdfset_versions)\n" | mail -s "ERROR: generate_lhapdf_version_number new projectnumber smaller" $notifytowhom
return 1
fi
LHAPDFSET_VERSION_NEW=${projectnumber}a
fi
else
LHAPDFSET_VERSION_NEW=$LHAPDFSET_VERSION_INITIAL
fi
echo $LHAPDFSET_VERSION_NEW
return 0
}
function create_lhapdf_softlink () {
installed=$1
what=$2
# Check 0
if [ $# -lt 2 ] ; then
echo ERROR create_lhapdf_softlink what+s+installed softlink4what
return 1
fi
grep "$installed" $HOME/lhapdf_list.txt
if [ $? -ne 0 ] ; then
echo ERROR $HOME/lhapdf_list.txt needs to be updated for $installed
return 1
fi
# Check 2
#lhapdfweb_updates=$(grep ^lhapdfweb_updates= $HOME/cron_download_lhapdf.sh | cut -d= -f2)
#for v in $lhapdfweb_updates ; do echo $v ; done | grep ${installed}$
#if [ $? -ne 0 ] ; then
# echo ERROR $HOME/cron_download_lhapdf.sh needs to be updated for $installed
# return 1
#fi
# Check 3
#ps auxwww | grep -v grep | grep shared | awk '{print $NF}' | grep cron_install_cmssw.sh | grep -v grep
#if [ $? -eq 0 ] ; then
# echo ERROR cron_install_cmssw.sh is running
# ps auxwww | grep shared | grep -v grep
# exit 1
#fi
#echo INFO backing up crontab and removing
#cd $HOME
#crontab=crontab.$(date +%s)
#crontab -l > $crontab
#if [ $? -eq 0 ] ; then
#crontab -r
#else
#rm -f $crontab
#crontab=crontab
#fi
#echo INFO softlinking
#./download_cron_script.sh
#cvmfs_server transaction
cd /cvmfs/cms.cern.ch/lhapdf/pdfsets
#rm -f 6.1.5
ln -s $installed $what
cd -
#ln -s $what current
#ln -s 6.1a 6.1.5
#cd
#echo INFO publishing the change
#cvmfs_server publish
#echo INFO restoring the crontab
#crontab $crontab
#crontab -l
echo INFO copying the checksum from ${lhapdf_top}/checksum_pdfsets_${installed}.txt to ${lhapdf_top}/checksum_pdfsets_${what}.txt
cp ${lhapdf_top}/checksum_pdfsets_${installed}.txt ${lhapdf_top}/checksum_pdfsets_${what}.txt
return 0
}
function higher_priority_gridpacks () {
printf "
/eos/cms/store/group/phys_generator/cvmfs/gridpacks/2017/13TeV/madgraph/V5_2.6.0/SingleLQ3ToTauB_5f/SingleLQ3ToTauB_5f_madgraph_LO_s-channel-M400_slc6_amd64_gcc481_CMSSW_7_1_30_tarball.tar.xz
/eos/cms/store/group/phys_generator/cvmfs/gridpacks/2017/13TeV/madgraph/V5_2.6.0/SingleLQ3ToTauB_5f/SingleLQ3ToTauB_5f_madgraph_LO_s-channel-M500_slc6_amd64_gcc481_CMSSW_7_1_30_tarball.tar.xz
/eos/cms/store/group/phys_generator/cvmfs/gridpacks/2017/13TeV/madgraph/V5_2.6.0/SingleLQ3ToTauB_5f/SingleLQ3ToTauB_5f_madgraph_LO_s-channel-M800_slc6_amd64_gcc481_CMSSW_7_1_30_tarball.tar.xz
/eos/cms/store/group/phys_generator/cvmfs/gridpacks/2017/13TeV/madgraph/V5_2.6.0/SingleLQ3ToTauB_5f/SingleLQ3ToTauB_5f_madgraph_LO_s-channel-M1200_slc6_amd64_gcc481_CMSSW_7_1_30_tarball.tar.xz
/eos/cms/store/group/phys_generator/cvmfs/gridpacks/2017/13TeV/madgraph/V5_2.6.0/SingleLQ3ToTauB_5f/SingleLQ3ToTauB_5f_madgraph_LO_t-channel-M500_slc6_amd64_gcc481_CMSSW_7_1_30_tarball.tar.xz
/eos/cms/store/group/phys_generator/cvmfs/gridpacks/2017/13TeV/madgraph/V5_2.6.0/SingleLQ3ToTauB_5f/SingleLQ3ToTauB_5f_madgraph_LO_t-channel-M1200_slc6_amd64_gcc481_CMSSW_7_1_30_tarball.tar.xz
/eos/cms/store/group/phys_generator/cvmfs/gridpacks/2017/13TeV/madgraph/V5_2.6.0/SingleLQ3ToTauB_5f/SingleLQ3ToTauB_5f_madgraph_LO_t-channel-M1500_slc6_amd64_gcc481_CMSSW_7_1_30_tarball.tar.xz
/eos/cms/store/group/phys_generator/cvmfs/gridpacks/2017/13TeV/madgraph/V5_2.6.0/SingleLQ3ToTauB_5f/SingleLQ3ToTauB_5f_madgraph_LO_pair-M400_slc6_amd64_gcc481_CMSSW_7_1_30_tarball.tar.xz
/eos/cms/store/group/phys_generator/cvmfs/gridpacks/2017/13TeV/madgraph/V5_2.6.0/SingleLQ3ToTauB_5f/SingleLQ3ToTauB_5f_madgraph_LO_pair-M500_slc6_amd64_gcc481_CMSSW_7_1_30_tarball.tar.xz
/eos/cms/store/group/phys_generator/cvmfs/gridpacks/2017/13TeV/madgraph/V5_2.6.0/SingleLQ3ToTauB_5f/SingleLQ3ToTauB_5f_madgraph_LO_pair-M600_slc6_amd64_gcc481_CMSSW_7_1_30_tarball.tar.xz
/eos/cms/store/group/phys_generator/cvmfs/gridpacks/2017/13TeV/madgraph/V5_2.6.0/SingleLQ3ToTauB_5f/SingleLQ3ToTauB_5f_madgraph_LO_pair-M800_slc6_amd64_gcc481_CMSSW_7_1_30_tarball.tar.xz
/eos/cms/store/group/phys_generator/cvmfs/gridpacks/2017/13TeV/madgraph/V5_2.6.0/SingleLQ3ToTauB_5f/SingleLQ3ToTauB_5f_madgraph_LO_pair-M900_slc6_amd64_gcc481_CMSSW_7_1_30_tarball.tar.xz
/eos/cms/store/group/phys_generator/cvmfs/gridpacks/2017/13TeV/madgraph/V5_2.6.0/SingleLQ3ToTauB_5f/SingleLQ3ToTauB_5f_madgraph_LO_pair-M1200_slc6_amd64_gcc481_CMSSW_7_1_30_tarball.tar.xz
/eos/cms/store/group/phys_generator/cvmfs/gridpacks/2017/13TeV/madgraph/V5_2.6.0/SingleLQ3ToTauB_5f/SingleLQ3ToTauB_5f_madgraph_LO_pair-M1500_slc6_amd64_gcc481_CMSSW_7_1_30_tarball.tar.xz
/eos/cms/store/group/phys_generator/cvmfs/gridpacks/2017/13TeV/madgraph/V5_2.6.0/SingleLQ3ToTauB_5f/SingleLQ3ToTauB_5f_madgraph_LO_pair-M2000_slc6_amd64_gcc481_CMSSW_7_1_30_tarball.tar.xz
/eos/cms/store/group/phys_generator/cvmfs/gridpacks/slc6_amd64_gcc481/13TeV/madgraph/V5_2.3.3/ggh01_M125_Toa01a01_M50_Totautautautau/v1/ggh01_M125_Toa01a01_M50_Totautautautau_tarball.tar.xz
/eos/cms/store/group/phys_generator/cvmfs/gridpacks/slc6_amd64_gcc481/13TeV/madgraph/V5_2.3.3/LLJJ_aTGC_EWK_SM_5f_LO/LLJJ_aTGC_EWK_SM_5f_LO_tarball-fixedMadspinCard_V1.tar.xz
/eos/cms/store/group/phys_generator/cvmfs/gridpacks/slc6_amd64_gcc481/13TeV/madgraph/V5_2.3.3/ChargedHiggs_GMmodel_HToWZ/SinglyChargedHiggsGMmodel_HWZ_M500_tarball.tar.xz
/eos/cms/store/group/phys_generator/cvmfs/gridpacks/slc6_amd64_gcc481/13TeV/madgraph/V5_2.3.3/ChargedHiggs_GMmodel_HToWZ/SinglyChargedHiggsGMmodel_HWZ_M500_tarball.tar.xz
/eos/cms/store/group/phys_generator/cvmfs/gridpacks/slc6_amd64_gcc481/13TeV/madgraph/V5_2.3.3/ggh01_M125_Toa01a01_M25_Tomumubb/v2/ggh01_M125_Toa01a01_M25_Tomumubb_tarball.tar.xz
/eos/cms/store/group/phys_generator/cvmfs/gridpacks/slc6_amd64_gcc481/13TeV/madgraph/V5_2.3.3/ggh01_M125_Toa01a01_M30_Tomumubb/v2/ggh01_M125_Toa01a01_M30_Tomumubb_tarball.tar.xz\n"
}
function eos () {
$EOSSYS/bin/eos.select
return $?
}
function eoscms () {
$EOSSYS/bin/eos.select
return $?
}
function eosforceumount () {
killall eosfsd 2>/dev/null
killall -9 eosfsd 2>/dev/null
fusermount -u $1
return $?
}
function cvmfs_create_an_lhapdf_version_from_two_versions () {
#cvmfs_create_an_lhapdf_version_from_two_versions 6.2.1a_2 6.2.1a_1 6.2.3c > cvmfs_create_an_lhapdf_version_from_two_versions+6.2.1a_2+6.2.1a_1+6.2.3c.log 2>&1 &
#newdir=/cvmfs/cms.cern.ch/lhapdf/pdfsets/6.2.1a_1
#[ -d $newdir ] || mkdir -p $newdir # mkdir -p /cvmfs/cms.cern.ch/lhapdf/pdfsets/6.2.1a_1
#sourcedir1=/cvmfs/cms.cern.ch/lhapdf/pdfsets/$(basename $newdir | sed 's#_# #g' | awk '{print $1}')
#sourcedir2=/cvmfs/cms.cern.ch/lhapdf/pdfsets/6.2.1d # current
if [ $# -lt 3 ] ; then
echo ERROR cvmfs_create_an_lhapdf_version_from_two_versions newversion version1 version2
return 1
fi
newversion=$1 ; version1=$2 ; version2=$3
newdir=/cvmfs/cms.cern.ch/lhapdf/pdfsets/$newversion
sourcedir1=/cvmfs/cms.cern.ch/lhapdf/pdfsets/$version1
sourcedir2=/cvmfs/cms.cern.ch/lhapdf/pdfsets/$version2
[ -d $newdir ] && { echo ERROR new directory already exists ; ls $newdir ; return 1 ; } ;
mkdir -p $newdir
[ ! -d $sourcedir1 ] && [ ! -L $sourcedir1 ] && { echo ERROR version1 directory does not exist = $sourcedir1 ; return 1 ; } ;
[ ! -d $sourcedir2 ] && [ ! -L $sourcedir2 ] && { echo ERROR version1 directory does not exist = $sourcedir2 ; return 1 ; } ;
count=0
for sourcedir in $sourcedir1 $sourcedir2 ; do
#echo Content in $sourcedir : $(ls $sourcedir | wc -l)
#echo Content in $sourcedir without pdfsets.index : $(ls $sourcedir | grep -v pdfsets.index | wc -l) $(wc -l $sourcedir/pdfsets.index | awk '{print $1}') $(i=0 ; for d in $sourcedir/* ; do [ -d $d ] || continue ; i=$(expr $i + 1) ; done ; echo $i)
cd $newdir # cd /cvmfs/cms.cern.ch/lhapdf/pdfsets/$newdir
for d in $(cat $sourcedir/pdfsets.index | awk '{print $2}') ; do
[ -L $d ] || { count=$(expr $count + 1) ; echo "[ $count ] $d " ; grep " $d " $sourcedir/pdfsets.index >> pdfsets.index ; ln -s $sourcedir/$d ; } ;
done
done
return 0
}
function cvmfs_check_an_lhapdf_version_from_two_versions () {
#newdir=/cvmfs/cms.cern.ch/lhapdf/pdfsets/6.2.1a_1
#[ -d $newdir ] || mkdir -p $newdir # mkdir -p /cvmfs/cms.cern.ch/lhapdf/pdfsets/6.2.1a_1
#sourcedir1=/cvmfs/cms.cern.ch/lhapdf/pdfsets/$(basename $newdir | sed 's#_# #g' | awk '{print $1}')
#sourcedir2=/cvmfs/cms.cern.ch/lhapdf/pdfsets/6.2.1d # current
if [ $# -lt 3 ] ; then
echo ERROR cvmfs_check_an_lhapdf_version_from_two_versions newversion version1 version2
return 1
fi
newversion=$1 ; version1=$2 ; version2=$3
newdir=/cvmfs/cms.cern.ch/lhapdf/pdfsets/$newversion
sourcedir1=/cvmfs/cms.cern.ch/lhapdf/pdfsets/$version1
sourcedir2=/cvmfs/cms.cern.ch/lhapdf/pdfsets/$version2
i=0
for d in $(cat $newdir/pdfsets.index | awk '{print $2}') ; do
i=$(expr $i + 1)
if [ -d $sourcedir1/$d ] ; then
if [ -d $sourcedir2/$d ] ; then
if [ "x$(grep ' $d ' $sourcedir1/pdfsets.index)" == "x$(grep ' $d ' $newdir/pdfsets.index)" ] ; then
echo "[ $i ] OK1 $d"
else
echo "[ $i ] BAD1 $d" #grep \" $d \" $sourcedir1/pdfsets.index "?" grep \" $d \" $newdir/pdfsets.index "|" grep \" $d \" $sourcedir2/pdfsets.index "?" grep \" $d \" $newdir/pdfsets.index
fi
else
echo "[ $i ] BAD2 $d" $sourcedir2 does not have this. Why?
fi
else
if [ -d $sourcedir2/$d ] ; then
if [ "x$(grep ' $d ' $sourcedir2/pdfsets.index)" == "x$(grep ' $d ' $newdir/pdfsets.index)" ] ; then
echo "[ $i ] OK2 $d"
else
echo "[ $i ] BAD3" #$(grep " $d " $sourcedir2/pdfsets.index) "?" $(grep " $d " $newdir/pdfsets.index)
fi
else
echo "[ $i ] BAD4"
fi
fi
done
}
function cvmfs_create_lhapdf_621a1 () {
newdir=/cvmfs/cms.cern.ch/lhapdf/pdfsets/6.2.1a_1
[ -d $newdir ] || mkdir -p $newdir # mkdir -p /cvmfs/cms.cern.ch/lhapdf/pdfsets/6.2.1a_1
sourcedir1=/cvmfs/cms.cern.ch/lhapdf/pdfsets/$(basename $newdir | sed 's#_# #g' | awk '{print $1}')
sourcedir2=/cvmfs/cms.cern.ch/lhapdf/pdfsets/6.2.1d # current
count=0
for sourcedir in $sourcedir1 $sourcedir2 ; do
#echo Content in $sourcedir : $(ls $sourcedir | wc -l)
#echo Content in $sourcedir without pdfsets.index : $(ls $sourcedir | grep -v pdfsets.index | wc -l) $(wc -l $sourcedir/pdfsets.index | awk '{print $1}') $(i=0 ; for d in $sourcedir/* ; do [ -d $d ] || continue ; i=$(expr $i + 1) ; done ; echo $i)
cd $newdir # cd /cvmfs/cms.cern.ch/lhapdf/pdfsets/$newdir
for d in $(cat $sourcedir/pdfsets.index | awk '{print $2}') ; do
[ -L $d ] || { count=$(expr $count + 1) ; echo "[ $count ] $d " ; grep " $d " $sourcedir/pdfsets.index >> pdfsets.index ; ln -s $sourcedir/$d ; } ;
done
done
return 0
}
function cvmfs_check_lhapdf_621a1 () {
newdir=/cvmfs/cms.cern.ch/lhapdf/pdfsets/6.2.1a_1
sourcedir1=/cvmfs/cms.cern.ch/lhapdf/pdfsets/$(basename $newdir | sed 's#_# #g' | awk '{print $1}')
sourcedir2=/cvmfs/cms.cern.ch/lhapdf/pdfsets/6.2.1d # current
i=0
for d in $(cat $newdir/pdfsets.index | awk '{print $2}') ; do
i=$(expr $i + 1)
if [ -d $sourcedir1/$d ] ; then
if [ -d $sourcedir2/$d ] ; then
if [ "x$(grep ' $d ' $sourcedir1/pdfsets.index)" == "x$(grep ' $d ' $newdir/pdfsets.index)" ] ; then
echo "[ $i ] OK1 $d"
else
echo "[ $i ] BAD1 $d" #grep \" $d \" $sourcedir1/pdfsets.index "?" grep \" $d \" $newdir/pdfsets.index "|" grep \" $d \" $sourcedir2/pdfsets.index "?" grep \" $d \" $newdir/pdfsets.index
fi
else
echo "[ $i ] BAD2 $d" $sourcedir2 does not have this. Why?
fi
else
if [ -d $sourcedir2/$d ] ; then
if [ "x$(grep ' $d ' $sourcedir2/pdfsets.index)" == "x$(grep ' $d ' $newdir/pdfsets.index)" ] ; then
echo "[ $i ] OK2 $d"
else
echo "[ $i ] BAD3" #$(grep " $d " $sourcedir2/pdfsets.index) "?" $(grep " $d " $newdir/pdfsets.index)
fi
else
echo "[ $i ] BAD4"
fi
fi
done
}
function cms_cvmfs_check_gridpacks_diff () {
[ -d $rsync_source ] || cms_cvmfs_mount_eos
for f in $(grep ^gridpacks/ $HOME/logs/gridpacks_schedule.txt ) ; do
if [ -f $(dirname $rsync_source)/$f ] ; then
if [ -f $(dirname $rsync_name)/$f ] ; then
echo 1 $f
else
echo 2 $(ls -al $(dirname $rsync_source)/$f) $(ls -al $(dirname $rsync_name)/$f)
fi
else
if [ -f $(dirname $rsync_name)/$f ] ; then
echo 3 $f
else
echo 4 $f
fi
fi
done
}
function cms_cvmfs_mount_eos () {
EOS_CLIENT_VERSION=${EOS_CLIENT_VERSION:-0.3.15}
export EOSSYS=/home/cvcms/eos_installation/${EOS_CLIENT_VERSION}
$EOSSYS/bin/eos.select -b fuse mount $HOME/eos2
return $?
}
function cms_cvmfs_umount_eos () {
EOS_CLIENT_VERSION=${EOS_CLIENT_VERSION:-0.3.15}
export EOSSYS=/home/cvcms/eos_installation/${EOS_CLIENT_VERSION}
$EOSSYS/bin/eos.select -b fuse umount $HOME/eos2
return $?
}
function cms_cvmfs_check_gridpacks() {
mounted_here=0
if [ ! -d /home/eos2/cms/store/group/phys_generator/cvmfs/gridpacks ] ; then
cms_cvmfs_mount_eos
echo INFO EOS mount status $?
mounted_here=1
fi
rsync_source="$HOME/eos2/cms/store/group/phys_generator/cvmfs/gridpacks"
rsync_name="/cvmfs/cms.cern.ch/phys_generator/gridpacks"
grep "tar.xz\|tar.gz\|tgz" $thelog | grep "^gridpacks/" | sort -u | \
while read f ; do
ls -al /home/cvcms/eos2/cms/store/group/phys_generator/cvmfs/$f
ls -al /cvmfs/cms.cern.ch/phys_generator/$f
done
if [ $mounted_here -eq 1 ] ; then
cms_cvmfs_umount_eos
fi
}
function cms_cvmfs_upload_file_to_florida () {
source /home/cvcms/osg/osg-wn-client/setup.sh
source_file=$1
if [ -f "$source_file" ] ; then
echo ERROR $source_file does not exist
return 1
fi
grep -q ^/ $source_file
[ $? -eq 0 ] || source_file=$(cd $(dirname $sourcefile) ; pwd)/$(basename $source_file)
globus-url-copy -vb file://$source_file gsiftp://cmsio.rc.ufl.edu/cms/t2/operations/cvmfs_installations/$(basename $source_file)
return $?
}
function cms_cvmfs_mgmt_fix_gridpack_perms_cron () {
cvmfs_server transaction
[ $? -eq 0 ] || { echo ERROR cvmfs_server transaction failed in cms_cvmfs_mgmt_fix_gridpack_perms_cron ; return 1 ; } ;
#echo cms_cvmfs_mgmt_fix_gridpack_perms > $HOME/cron_install_cmssw.lock
#echo INFO $HOME/cron_install_cmssw.lock created
n=0
for f in $(find /cvmfs/cms.cern.ch/phys_generator/gridpacks/ -type f -name "*" -print) ; do
themode=$(/usr/bin/stat -c %a $f)
if [ $themode -lt 400 ] ; then
n=$(expr $n + 1)
echo chmod 644 $f
chmod 644 $f
fi
if [ $(echo $themode | cut -c2-) -lt 40 ] ; then
n=$(expr $n + 1)
echo chmod 644 $f
chmod 644 $f
fi
if [ $(echo $themode | cut -c3-) -lt 4 ] ; then
n=$(expr $n + 1)
echo chmod 644 $f
chmod 644 $f
fi
done
for d in $(find /cvmfs/cms.cern.ch/phys_generator/gridpacks/ -type d -name "*" -print) ; do
themode=$(/usr/bin/stat -c %a $d)
if [ $themode -lt 500 ] ; then
n=$(expr $n + 1)
echo chmod 755 $d
chmod 755 $d
fi
if [ $(echo $themode | cut -c2-) -lt 50 ] ; then
n=$(expr $n + 1)
echo chmod 755 $d
chmod 755 $d
fi
if [ $(echo $themode | cut -c3-) -lt 5 ] ; then
n=$(expr $n + 1)
echo chmod 755 $d
chmod 755 $d
fi
done
if [ $n -gt 0 ] ; then
cvmfs_server publish
else
cvmfs_server abort -f
fi
#echo INFO removing $HOME/cron_install_cmssw.lock
#rm -f $HOME/cron_install_cmssw.lock
}
function cms_cvmfs_mgmt_fix_gridpack_perms () {
cvmfs_server transaction
[ $? -eq 0 ] || return 1
echo cms_cvmfs_mgmt_fix_gridpack_perms > $HOME/cron_install_cmssw.lock
echo INFO $HOME/cron_install_cmssw.lock created
n=0
for f in $(find /cvmfs/cms.cern.ch/phys_generator/gridpacks/ -type f -name "*" -print) ; do
themode=$(/usr/bin/stat -c %a $f)
if [ $themode -lt 400 ] ; then
n=$(expr $n + 1)
echo chmod 644 $f
chmod 644 $f
fi
if [ $(echo $themode | cut -c2-) -lt 40 ] ; then
n=$(expr $n + 1)
echo chmod 644 $f
chmod 644 $f
fi
if [ $(echo $themode | cut -c3-) -lt 4 ] ; then
n=$(expr $n + 1)
echo chmod 644 $f
chmod 644 $f
fi
done
for d in $(find /cvmfs/cms.cern.ch/phys_generator/gridpacks/ -type d -name "*" -print) ; do
themode=$(/usr/bin/stat -c %a $d)
if [ $themode -lt 500 ] ; then
n=$(expr $n + 1)
echo chmod 755 $d
chmod 755 $d
fi
if [ $(echo $themode | cut -c2-) -lt 50 ] ; then
n=$(expr $n + 1)
echo chmod 755 $d
chmod 755 $d
fi
if [ $(echo $themode | cut -c3-) -lt 5 ] ; then
n=$(expr $n + 1)
echo chmod 755 $d
chmod 755 $d
fi
done
if [ $n -gt 0 ] ; then
cvmfs_server publish
else
cvmfs_server abort -f
fi
echo INFO removing $HOME/cron_install_cmssw.lock
rm -f $HOME/cron_install_cmssw.lock
}
function day_and_even_odd_combination () {
BACKUP_DATE=$(date +%Y%m%d)
BACKUP_EVEN_ODD=1
[ $(expr $BACKUP_DATE % 2) -eq 0 ] && BACKUP_EVEN_ODD=0
if [ $(expr $(date --date="1 day ago" +%Y%m%d) % 2) -eq 0 ] ; then
BACKUP_EVEN_ODD_YTD=0
else
BACKUP_EVEN_ODD_YTD=1
fi
[ $BACKUP_EVEN_ODD_YTD -eq $BACKUP_EVEN_ODD ] && BACKUP_EVEN_ODD=2
echo $BACKUP_EVEN_ODD
}
function T2_host_sleep_time () {
# generate a random sleep time between 48 second 3600
sleep_time=$(echo $(( RANDOM % (3600 - 48 + 1 ) + 48 )))
[ $(/bin/hostname -f) == archer.ihepa.ufl.edu ] && { sleep_time=1 ; echo $sleep_time ; return 0 ; } ;
[ $(/bin/hostname -f) == alachua.ihepa.ufl.edu ] && { sleep_time=5 ; echo $sleep_time ; return 0 ; } ;
[ $(/bin/hostname -f) == newberry.ihepa.ufl.edu ] && { sleep_time=7 ; echo $sleep_time ; return 0 ; } ;
[ $(/bin/hostname -f) == melrose.ihepa.ufl.edu ] && { sleep_time=9 ; echo $sleep_time ;return 0 ; } ;
[ $(/bin/hostname -f) == oo.ihepa.ufl.edu ] && { sleep_time=10 ; echo $sleep_time ; return 0 ; } ;
[ $(/bin/hostname -f) == xrootd2.ihepa.ufl.edu ] && { sleep_time=15 ; echo $sleep_time ; return 0 ; } ;
[ $(/bin/hostname -f) == phedexb.ihepa.ufl.edu ] && { sleep_time=20 ; echo $sleep_time ; return 0 ; } ;
echo $sleep_time
return 0
}
function rsync_cvmfs_cms_cern_ch_to_cms_cvmfs () {
NCYCLE=$(grep /usr/local/bin/cvmfs-rsync.sh /etc/cron.d/cvmfs-rsync 2>/dev/null | awk '{print $2}' | cut -d/ -f2)
[ "x$(echo $NCYCLE)" == "x" ] && NCYCLE=6
sleep_time=$(T2_host_sleep_time)
echo INFO starting rsync_cvmfs_cms_cern_ch_to_cms_cvmfs ICYCLE=$(expr $(date +%H) / $NCYCLE) NCYCLE=$NCYCLE Sleeping for $sleep_time
# Run it every NCYCLE (default=6) hours with a machine-dependent sleep time
#sleep_time=$(T2_host_sleep_time)
sleep $sleep_time
db_backup=/cms/data/store/local/cvmfs/cms.cern.ch/cvmfs_cms_cern_ch_backup.db.txt
[ -f $db_backup ] || touch $db_backup
BACKUP_SECONDS=$(expr 60 \* 59)
BACKUP_COMMAND="lcg-cp -b --vo cms -D srmv2 -T srmv2 -v"
starttime=$(date +%s)
BACKUP_LIST=$(cd /cvmfs/cms.cern.ch ; for d in * ; do echo $d ; done)
BACKUP_DATE=$(date +%Y%m%d)
BACKUP_CYCLE=$(expr $(date +%H ) / $NCYCLE)
#BACKUP_UP=/cms/data/store/local/cvmfs/cms.cern.ch #/$(day_and_even_odd_combination)
BACKUP_UP=/cms/cvmfs/cms.cern.ch
thelock=${BACKUP_UP}/.rsync.$(/bin/hostname -f).lock
if [ -f $thelock ] ; then
echo INFO $thelock exists cat $thelock
printf "$(/bin/hostname -f): rsync_cvmfs_cms_cern_ch_to_cms_cvmfs: rsync is still running\n$(cat $thelock)\n" | mail -s "rsync_cvmfs_cms_cern_ch_to_cms_cvmfs: rsync locked" $notifytowhom
return 0
else
echo INFO creating $thelock
echo $(/bin/hostname -f) $(date) $(date +%s) > $thelock
fi
echo $(date)
cd /cvmfs/cms.cern.ch
#ndone=$(for b in $BACKUP_LIST ; do ls ${BACKUP_UP}/${b}.lock ; done | wc -l)
#if [ $ndone -eq $(echo $BACKUP_LIST | wc -w) ] ; then
# printf "$(/bin/hostname -f): rsync_cvmfs_cms_cern_ch_to_cms_cvmfs: rsync done for this cycle\n" | mail -s "rsync_cvmfs_cms_cern_ch_to_cms_cvmfs: rsync done" $notifytowhom
# for b in $BACKUP_LIST ; do rm -f ${BACKUP_UP}/${b}.lock ; done
#fi
for b in $BACKUP_LIST ; do
echo INFO Checking and doing "$b"
#[ $(expr $(date +%s) - $starttime) -gt $BACKUP_SECONDS ] && break
# if it is already in the db, skip it
grep -q "$BACKUP_DATE $BACKUP_CYCLE ${b}.rsync" $db_backup
[ $? -eq 0 ] && continue
# if something else is doing the job, skip it
[ -f ${BACKUP_UP}/.${b}.lock ] && continue
# claim the task first
STARTTIME=$(date +%s)
echo INFO "$b" Starting at $(/bin/hostname -f) $(date) $STARTTIME > ${BACKUP_UP}/.${b}.lock
echo INFO "$b" $(date) STARTED executing rsync -arupq --delete /cvmfs/cms.cern.ch/${b} ${BACKUP_UP}
rsync -arupq --delete /cvmfs/cms.cern.ch/${b} ${BACKUP_UP}
status=$?
ENDTIME=$(date +%s)
if [ $(expr $ENDTIME - $STARTTIME) -gt 1800 ] ; then
printf "$(/bin/hostname -f): INFO rsync_cvmfs_cms_cern_ch_to_cms_cvmfs: rsync -arupq --delete /cvmfs/cms.cern.ch/${b} ${BACKUP_UP} just finished\n" | mail -s "INFO rsync_cvmfs_cms_cern_ch_to_cms_cvmfs" $notifytowhom
fi
if [ $status -ne 0 ] ; then
echo INFO $(date) ERROR for ${b}
printf "$(/bin/hostname -f): ERROR rsync_cvmfs_cms_cern_ch_to_cms_cvmfs: rsync error for ${b}\n" | mail -s "ERROR rsync_cvmfs_cms_cern_ch_to_cms_cvmfs" $notifytowhom
fi
echo INFO $(date) ENDED executing rsync -arupq --delete /cvmfs/cms.cern.ch/${b} ${BACKUP_UP}
#if [ $status -eq 0 ] ; then
grep -q "$BACKUP_DATE $BACKUP_CYCLE ${b}.rsync" $db_backup
if [ $? -ne 0 ] ; then
echo $BACKUP_DATE $BACKUP_CYCLE ${b}.rsync >> $db_backup
fi
#fi
echo INFO $(date) Done $b with status=$status
rm -f ${BACKUP_UP}/.${b}.lock
done
cd -
BACKUP_DATE_ADAY_AGO=$(date --date="1 day ago")
#sed -i "/$(echo $BACKUP_DATE_ADAY_AGO | sed 's^/^\\\/^g')/ d" $db_backup
rm -f $thelock
return 0
}
function backup_installation_to_T2_US_Florida () {
# Run it every 6 hours
#HNOW=$(date +%H)
#[ $HNOW -gt 9 -a $HNOW -le 11 ] && return 0
#[ $HNOW -gt 21 -a $HNOW -le 23 ] && return 0
#export X509_USER_PROXY=$HOME/.florida.t2.proxy
#export X509_USER_PROXY=/raid/raid5/cms/bockjoo/cms_analysis/phedex_proxy
# Run
db_backup=/cms/data/store/local/cvmfs/cms.cern.ch/cvmfs_cms_cern_ch_backup.db.txt
[ -f $db_backup ] || touch $db_backup
BACKUP_SECONDS=$(expr 60 \* 59)
#BACKUP_SOURCE=$HOME/cvmfs_backup
#BACKUP_UP=srm://srm.ihepa.ufl.edu:8443/srm/v2/server?SFN=/cms/data/store/local/cvmfs/cms.cern.ch
BACKUP_COMMAND="lcg-cp -b --vo cms -D srmv2 -T srmv2 -v"
#[ -d $BACKUP_SOURCE ] || mkdir -p $BACKUP_SOURCE
starttime=$(date +%s)
BACKUP_ALL=$(cd /cvmfs/cms.cern.ch ; for d in * ; do echo $d ; done)
BACKUP_EVEN_ODD=$(day_and_even_odd_combination)
BACKUP_DATE=$(date +%Y%m%d)
BACKUP_CYCLE=$(expr $(date +%H ) / 6)
BACKUP_UP=/cms/data/store/local/cvmfs/cms.cern.ch/${BACKUP_EVEN_ODD}
#BACKUP_UP=/cms/cvmfs/cms.cern.ch
#while [ $(expr $(date +%s) - $starttime) -lt $BACKUP_SECONDS ] ; do # stall only the thing in one hour
echo $(date)
cd /cvmfs/cms.cern.ch
ndone=$(for b in $BACKUP_ALL ; do ls ${BACKUP_UP}/${b}.lock ; done | wc -l)
if [ $ndone -eq $(echo $BACKUP_ALL | wc -w) ] ; then
printf "$(/bin/hostname -f): backup_installation_to_T2_US_Florida: rsync done for this cycle\n" | mail -s "backup_installation_to_T2_US_Florida: rsync done" $notifytowhom
for b in $BACKUP_ALL ; do rm -f ${BACKUP_UP}/${b}.lock ; done
fi
for b in $BACKUP_ALL ; do
#[ $(expr $(date +%s) - $starttime) -gt $BACKUP_SECONDS ] && break
[ -f ${BACKUP_UP}/.${b} ] && continue # if something else is doing the job, skip it
grep -q "$BACKUP_DATE $BACKUP_CYCLE ${b}.rsync" $db_backup # if it is already in the db, skip it
[ $? -eq 0 ] && continue
touch ${BACKUP_UP}/${b}.lock
#echo INFO $(date) STARTED executing tar czf ${BACKUP_UP}/${b}.tar.gz ${b}
#tar czf ${BACKUP_SOURCE}/${b}.tar.gz ${b}
#1 tar czf ${BACKUP_UP}/${b}.tar.gz ${b}
echo INFO $(date) STARTED executing rsync -arupq --delete /cvmfs/cms.cern.ch/${b} ${BACKUP_UP}
rsync -arupq --delete /cvmfs/cms.cern.ch/${b} ${BACKUP_UP}
status=$?
#[ $? -eq 0 ] || { echo INFO $(date) ENDED failed execution of tar czf ${BACKUP_UP}/${b}.tar.gz ${b} ; break ; } ;
[ $status -eq 0 ] || { echo INFO $(date) ERROR for ${b} ; } ;
echo INFO $(date) ENDED executing rsync -arupq --delete /cvmfs/cms.cern.ch/${b} ${BACKUP_UP}
#echo INFO $(date) ENDED executing tar czf ${BACKUP_UP}/${b}.tar.gz ${b}
#lcg-cp -b --vo cms -D srmv2 -T srmv2 -v file://${BACKUP_SOURCE}/${b}.tar.gz ${BACKUP_UP}/${BACKUP_EVEN_ODD}/${b}.tar.gz
if [ $status -eq 0 ] ; then
grep -q "$BACKUP_DATE $BACKUP_CYCLE ${b}.rsync" $db_backup
[ $? -eq 0 ] || echo $BACKUP_DATE ${b}.rsync >> $db_backup
fi
#rm -f ${BACKUP_SOURCE}/${b}.tar.gz
done
cd -
sleep 1
#done
return 0
}
function backup_installation () {
export X509_USER_PROXY=$HOME/.florida.t2.proxy
db_backup=$HOME/cvmfs_cms_cern_ch_backup.db.txt
[ -f $db_backup ] || touch $db_backup
BACKUP_SECONDS=$(expr 60 \* 59)
BACKUP_SOURCE=$HOME/cvmfs_backup
BACKUP_UP=srm://srm.ihepa.ufl.edu:8443/srm/v2/server?SFN=/cms/data/store/local/cvmfs/cms.cern.ch
BACKUP_UP=gsiftp://gridftp3.ihepa.ufl.edu///raid/raid8/cvmfs/cms.cern.ch
BACKUP_COMMAND="lcg-cp -b --vo cms -D srmv2 -T srmv2 -v"
[ -d $BACKUP_SOURCE ] || mkdir -p $BACKUP_SOURCE
starttime=$(date +%s)
BACKUP_ALL=$(cd /cvmfs/cms.cern.ch ; for d in * ; do echo $d ; done)
BACKUP_DATE=$(date +%Y%m%d)
BACKUP_EVEN_ODD=1
[ $(expr $BACKUP_DATE % 2) -eq 0 ] && BACKUP_EVEN_ODD=0
BACKUP_EVEN_ODD=
while [ $(expr $(date +%s) - $starttime) -lt $BACKUP_SECONDS ] ; do # stall only the thing in one hour
echo $(date)
cd /cvmfs/cms.cern.ch
for b in $BACKUP_ALL ; do
[ $(expr $(date +%s) - $starttime) -gt $BACKUP_SECONDS ] && break
grep -q "$BACKUP_DATE ${b}.tar.gz" $db_backup
[ $? -eq 0 ] && continue
echo INFO $(date) STARTED executing tar czf ${BACKUP_SOURCE}/${b}.tar.gz ${b}
tar czf ${BACKUP_SOURCE}/${b}.tar.gz ${b}
[ $? -eq 0 ] || { echo INFO $(date) ENDED executing tar czf ${BACKUP_SOURCE}/${b}.tar.gz ${b} ; break ; } ;
echo INFO $(date) ENDED executing tar czf ${BACKUP_SOURCE}/${b}.tar.gz ${b}
lcg-cp -b --vo cms -D srmv2 -T srmv2 -v file://${BACKUP_SOURCE}/${b}.tar.gz ${BACKUP_UP}/${BACKUP_EVEN_ODD}/${b}.tar.gz
if [ $? -eq 0 ] ; then
grep -q "$BACKUP_DATE ${b}.tar.gz" $db_backup
[ $? -eq 0 ] || echo $BACKUP_DATE ${b}.tar.gz >> $db_backup
fi
rm -f ${BACKUP_SOURCE}/${b}.tar.gz
done
cd -
sleep 1
done
return 0
}
function backup_installation_one () {
b=$1
export X509_USER_PROXY=$HOME/.florida.t2.proxy
db_backup=$HOME/cvmfs_cms_cern_ch_backup.db.txt
[ -f $db_backup ] || touch $db_backup
BACKUP_SECONDS=$(expr 60 \* 59)
BACKUP_SOURCE=$HOME/cvmfs_backup
BACKUP_UP=srm://srm.ihepa.ufl.edu:8443/srm/v2/server?SFN=/cms/data/store/local/cvmfs/cms.cern.ch
#BACKUP_UP=gsiftp://gridftp3.ihepa.ufl.edu///raid/raid8/cvmfs/cms.cern.ch
BACKUP_COMMAND="lcg-cp -b --vo cms -D srmv2 -T srmv2 -v"
[ -d $BACKUP_SOURCE ] || mkdir -p $BACKUP_SOURCE
starttime=$(date +%s)
#BACKUP_ALL=$(cd /cvmfs/cms.cern.ch ; for d in * ; do echo $d ; done)
BACKUP_ALL=$(for d in $(ls /cvmfs/cms.cern.ch | grep slc6_ | grep -v slc6_mic) ; do echo $d ; done)
BACKUP_DATE=$(date +%Y%m%d)
#BACKUP_EVEN_ODD=1
#[ $(expr $BACKUP_DATE % 2) -eq 0 ] && BACKUP_EVEN_ODD=0
#BACKUP_EVEN_ODD=
#while [ $(expr $(date +%s) - $starttime) -lt $BACKUP_SECONDS ] ; do # stall only the thing in one hour
# echo $(date)
cd /cvmfs/cms.cern.ch
for b in $BACKUP_ALL ; do
# [ $(expr $(date +%s) - $starttime) -gt $BACKUP_SECONDS ] && break
grep -q "${b}.tar.gz" $db_backup | grep -q "$(date +%Y%m)"
[ $? -eq 0 ] && continue
echo INFO $(date) STARTED executing tar czf ${BACKUP_SOURCE}/${b}.tar.gz ${b}
tar czf ${BACKUP_SOURCE}/${b}.tar.gz ${b}
[ $? -eq 0 ] || { echo INFO $(date) FAILED executing tar czf ${BACKUP_SOURCE}/${b}.tar.gz ${b} ; printf "backup_installation_one(): tar czf ${BACKUP_SOURCE}/${b}.tar.gz ${b} failed\n" | mail -s "tar czf failed" $notifytowhom ; } ;
echo INFO $(date) ENDED executing tar czf ${BACKUP_SOURCE}/${b}.tar.gz ${b}
lcg-cp -b --vo cms -D srmv2 -T srmv2 -v file://${BACKUP_SOURCE}/${b}.tar.gz ${BACKUP_UP}/${BACKUP_EVEN_ODD}/${b}.tar.gz
if [ $? -eq 0 ] ; then
printf "backup_installation_one(): lcg-cp OK\nCheck $(echo $BACKUP_UP | cut -d= -f2-)/${b}.tar.gz\n" | mail -s "lcg-cp OK for $b" $notifytowhom
else
printf "backup_installation_one(): lcg-cp failed for $b\n" | mail -s "lcg-cp failed" $notifytowhom
fi
grep -q "$BACKUP_DATE ${b}.tar.gz" $db_backup
[ $? -eq 0 ] || echo $BACKUP_DATE ${b}.tar.gz >> $db_backup
#fi
rm -f ${BACKUP_SOURCE}/${b}.tar.gz
break # do other work too
done
cd -
#sleep 1
#done
return 0
}
function deploy_cmspkg () {
[ $# -lt 3 ] && { echo ERROR deploy_cmspkg path arch repo ; return 1 ; } ;
swpath=$1 # /cvmfs/cms.cern.ch/crab3
ARCH=$2 # slc6_amd64_gcc493
REPO=$3 # comp
cd /tmp
echo INFO downloading cmspkg.py
wget https://raw.githubusercontent.com/cms-sw/cmspkg/production/client/cmspkg.py
[ $? -eq 0 ] || { echo ERROR wget cmspkg.py failed ; rm -f cmspkg.py ; cd - ; return 1 ; } ;
[ -f $HOME/cron_install_cmssw.lock ] && { echo ERROR cron_install_cmssw.lock exists ; rm -f cmspkg.py ; cd - ; return 1 ; } ;
[ -f $HOME/cron_install_cmssw.lock ] || { echo INFO creating cron_install_cmssw.lock at /home/cvcms ; touch cron_install_cmssw.lock ; } ;
cvmfs_server transaction
python cmspkg.py --architecture $ARCH --path $swpath --repository comp setup
status=$?
[ -f $swpath/common/cmspkg ] || { echo ERROR cmspkg is not installed ; rm -f cmspkg.py ; return 1 ; } ;
rm -f cmspkg.py
cd
cvmfs_server publish
status=$(expr $status + $?)
rm -f $HOME/cron_install_cmssw.lock
return $status
}
# See https://github.com/cms-sw/cms-bot/blob/master/dockerrun.sh
function dockerrun() {
WORKDIR=$THISDIR
case "$SCRAM_ARCH" in
slc6_amd64_* )
if [ ] ; then
docker pull $DOCKER_TAG_SLC6
DOC_ARG="run --net=host -u $(id -u):$(id -g) --rm -t"
DOC_ARG="${DOC_ARG} -e THISDIR=${THISDIR} -e WORKDIR=${WORKDIR} -e SCRAM_ARCH=${SCRAM_ARCH}"
DOC_ARG="${DOC_ARG} -v ${THISDIR}:${THISDIR} -v /cvmfs:/cvmfs -v ${WORKDIR}:${WORKDIR}"
ARGS="cd $THISDIR; for o in n s u ; do val=\"-\$o \$(ulimit -H -\$o) \${val}\"; done; ulimit \${val}; ulimit -n -s -u; $@"
docker $DOC_ARG ${IMG} sh -c "$ARGS"
fi
#IMG="cmssw/slc6:latest"
ARGS="cd $THISDIR; $@"
#ARGS="cd $THISDIR; for o in n s u ; do val=\"-\$o \$(ulimit -H -\$o) \${val}\"; done; ulimit \${val}; ulimit -n -s -u; $@"
echo INFO checking docker images ARGS="|"$ARGS"|"
docker images 2>/dev/null | grep $(echo $DOCKER_TAG_SLC6 | cut -d: -f1) | grep -q $(echo $DOCKER_TAG_SLC6 | cut -d: -f2)
[ $? -eq 0 ] || { echo ERROR docker image $DOCKER_TAG_SLC6 not found ; return 1 ; } ;
echo INFO running docker run --net=host -u $(id -u):$(id -g) --rm -i -v /tmp:/tmp -v /cvmfs:/cvmfs -v ${workdir}:${workdir} $DOCKER_TAG_SLC6 sh -c "$ARGS"
#docker run --rm -it -v /tmp:/tmp -v /cvmfs:/cvmfs -v ${workdir}:${workdir} -u $(whoami) $DOCKER_TAG sh -c "$ARGS"
#docker run --rm -i -v /tmp:/tmp -v /cvmfs:/cvmfs -v ${workdir}:${workdir} -u $(whoami) $DOCKER_TAG sh -c "$ARGS"
docker run --net=host -u $(id -u):$(id -g) --rm -i -v /tmp:/tmp -v /cvmfs:/cvmfs -v ${workdir}:${workdir} $DOCKER_TAG_SLC6 sh -c "$ARGS" 2>&1
status=$?
echo INFO done running docker run ... status=$status
return $status
;;
slc7_amd64_* )
ARGS="cd $THISDIR; $@"
echo INFO checking docker images ARGS="|"$ARGS"|"
docker images 2>/dev/null | grep $(echo $DOCKER_TAG | cut -d: -f1) | grep -q $(echo $DOCKER_TAG | cut -d: -f2)
[ $? -eq 0 ] || { echo ERROR docker image $DOCKER_TAG not found ; return 1 ; } ;
echo INFO running docker run --net=host -u $(id -u):$(id -g) --rm -i -v /tmp:/tmp -v /cvmfs:/cvmfs -v ${workdir}:${workdir} $DOCKER_TAG sh -c "$ARGS"
#docker run --rm -it -v /tmp:/tmp -v /cvmfs:/cvmfs -v ${workdir}:${workdir} -u $(whoami) $DOCKER_TAG sh -c "$ARGS"
#docker run --rm -i -v /tmp:/tmp -v /cvmfs:/cvmfs -v ${workdir}:${workdir} -u $(whoami) $DOCKER_TAG sh -c "$ARGS"
docker run --net=host -u $(id -u):$(id -g) --rm -i -v /tmp:/tmp -v /cvmfs:/cvmfs -v ${workdir}:${workdir} $DOCKER_TAG sh -c "$ARGS" 2>&1
status=$?
echo INFO done running docker run ... status=$status
return $status
;;
cc8_amd64_* )
if [ ] ; then
docker pull $DOCKER_TAG_SLC8
DOC_ARG="run --net=host -u $(id -u):$(id -g) --rm -t"
DOC_ARG="${DOC_ARG} -e THISDIR=${THISDIR} -e WORKDIR=${WORKDIR} -e SCRAM_ARCH=${SCRAM_ARCH}"
DOC_ARG="${DOC_ARG} -v ${THISDIR}:${THISDIR} -v /cvmfs:/cvmfs -v ${WORKDIR}:${WORKDIR}"
ARGS="cd $THISDIR; for o in n s u ; do val=\"-\$o \$(ulimit -H -\$o) \${val}\"; done; ulimit \${val}; ulimit -n -s -u; $@"
docker $DOC_ARG ${IMG} sh -c "$ARGS"
fi
#IMG="cmssw/slc6:latest"
ARGS="cd $THISDIR; $@"
#ARGS="cd $THISDIR; for o in n s u ; do val=\"-\$o \$(ulimit -H -\$o) \${val}\"; done; ulimit \${val}; ulimit -n -s -u; $@"
echo INFO checking docker images ARGS="|"$ARGS"|"
docker images 2>/dev/null | grep $(echo $DOCKER_TAG_SLC8 | cut -d: -f1) | grep -q $(echo $DOCKER_TAG_SLC8 | cut -d: -f2)
[ $? -eq 0 ] || { echo ERROR docker image $DOCKER_TAG_SLC8 not found ; return 1 ; } ;
echo INFO running docker run --net=host -u $(id -u):$(id -g) --rm -i -v /tmp:/tmp -v /cvmfs:/cvmfs -v ${workdir}:${workdir} $DOCKER_TAG_SLC8 sh -c "$ARGS"
#docker run --rm -it -v /tmp:/tmp -v /cvmfs:/cvmfs -v ${workdir}:${workdir} -u $(whoami) $DOCKER_TAG sh -c "$ARGS"
#docker run --rm -i -v /tmp:/tmp -v /cvmfs:/cvmfs -v ${workdir}:${workdir} -u $(whoami) $DOCKER_TAG sh -c "$ARGS"
docker run --net=host -u $(id -u):$(id -g) --rm -i -v /tmp:/tmp -v /cvmfs:/cvmfs -v ${workdir}:${workdir} $DOCKER_TAG_SLC8 sh -c "$ARGS" 2>&1
status=$?
echo INFO done running docker run ... status=$status
return $status
;;
* )
eval $@
return $?
;;
esac
}
function dockerrun_ib()
{
case "$SCRAM_ARCH" in
slc7_amd64_* )
ARGS="cd $THISDIR; $@"
docker run --rm -t -e THISDIR=${THISDIR} -e WORKDIR=${WORKDIR} -e SCRAM_ARCH=${SCRAM_ARCH} -e x=${x} -v /tmp:/tmp -v ${WORKDIR}:${WORKDIR} -v ${THISDIR}:${THISDIR} -u $(whoami) cmssw/slc7-installer:latest sh -c "$ARGS"
;;
slc7_aarch64_* )
ARGS="export THISDIR=${THISDIR}; export WORKDIR=${WORKDIR}; export SCRAM_ARCH=${SCRAM_ARCH}; export x=${x}; cd ${THISDIR}; $@"
$PROOTDIR/proot -R $PROOTDIR/centos-7.2.1511-aarch64-rootfs -b /tmp:tmp -b /build:/build -b /cvmfs:/cvmfs -w ${THISDIR} -q "$PROOTDIR/qemu-aarch64 -cpu cortex-a57" sh -c "$ARGS"
;;
fc22_ppc64le_* )
ARGS="export THISDIR=${THISDIR}; export WORKDIR=${WORKDIR}; export SCRAM_ARCH=${SCRAM_ARCH}; export x=${x}; cd ${THISDIR}; $@"
$PROOTDIR/proot -R $PROOTDIR/fedora-22-ppc64le-rootfs -b /tmp:/tmp -b /build:/build -b /cvmfs:/cvmfs -w ${THISDIR} -q "$PROOTDIR/qemu-ppc64le -cpu POWER8" sh -c "$ARGS"
;;
* )
eval $@
;;
esac
}
function list_requested_cmssw_archs () { # This function needs a manual edition
echo slc6_amd64_gcc472
cat $dev_arch_cmssws 2>/dev/null | grep slc | awk '{print $1}' | sort -u
echo cc8_amd64_gcc8
return 0
}
function list_requested_arch_cmssws () { # This function needs a manual edition
echo slc6_amd64_gcc472 CMSSW_5_3_11
echo slc6_amd64_gcc472 CMSSW_5_3_11_patch1
echo slc6_amd64_gcc472 CMSSW_5_3_11_patch2
echo slc6_amd64_gcc472 CMSSW_5_3_11_patch3
echo slc6_amd64_gcc472 CMSSW_5_3_11_patch5
cat $dev_arch_cmssws 2>/dev/null | grep slc | grep CMSSW
# 12/2/2014
# There are cases when the release manager did not add the release to the tagxml
# https://cmssdt.cern.ch/SDT/cgi-bin/ReleasesXML?anytype=1
# /usr/bin/wget -q -O- --connect-timeout=360 --read-timeout=360 http://oo.ihepa.ufl.edu:8080/cmssoft/list_requested_arch_cmssws_cvmfs.txt 2>/dev/null
cat $HOME/list_requested_arch_cmssws_cvmfs.txt 2>/dev/null
echo cc8_amd64_gcc8 CMSSW_11_1_0_pre1
return 0
}
function list_announced_all_cmssw_archs () {
CMSSW_REPO=cms
curl http://cmsrep.cern.ch/cgi-bin/repos/$CMSSW_REPO 2>/dev/null | cut -d\> -f2 | cut -d\< -f1 | sort -u | grep -v $archs_excluded
}
function list_announced_cmssw_slc_amd_archs () {
#CMSSW_REPO=cms
#curl http://cmsrep.cern.ch/cgi-bin/repos/$CMSSW_REPO 2>/dev/null | grep slc[0-9]_amd64_| cut -d\> -f2 | cut -d\< -f1 | sort -u | grep -v $archs_excluded
list_announced_all_cmssw_archs | grep slc[0-9]_amd64_ | grep -v $archs_excluded
}
function list_announced_cmssw_archs () {
a_archs=$(cat "$releases_map_local" | cut -d\; -f1 | cut -d= -f2 | sort -u | grep slc | grep -v slc3_ | grep -v slc4_ | grep -v slc5_ia32_)
r_archs=$(list_requested_cmssw_archs)
for the_arch in $a_archs $r_archs ; do
for arch_e in $archs_excluded ; do
echo "+"${arch_e}"+"
done | grep -q "+"${the_arch}"+"
[ $? -eq 0 ] && continue
echo $the_arch
done | sort -u
return 0
}
function list_announced_arch_cmssws_cmspkg_way () {
export CMSSW_REPO=cms # $crab3repos
export SCRAM_ARCH=$1
cvmfs_server transaction 2>&1 | tee $HOME/logs/cvmfs_server+transaction.log
[ $? -eq 0 ] || { printf "ERROR: function list_announced_arch_cmssws cvmfs_server transaction failed\n$(cat $HOME/logs/cvmfs_server+transaction.log)\n" | mail -s "ERROR: cvmfs_server transaction failed for list_announced_arch_cmssws" $notifytowhom ; ( cd ; cvmfs_server abort -f ; ) ; return 1 ; } ;
CMSPKG="$VO_CMS_SW_DIR/common/cmspkg -a $SCRAM_ARCH"
#echo INFO executing $CMSPKG -y upgrade
$CMSPKG -y upgrade 2>/dev/null 1>/dev/null
status=$?
if [ $status -ne 0 ] ; then
#echo ERROR $CMSPKG -y upgrade upgrade failed
( cd ; cvmfs_server abort -f ; ) ;
return 1
fi
$CMSPKG update 2>/dev/null 1>/dev/null
status=$?
if [ $status -ne 0 ] ; then
#echo ERROR $CMSPKG update failed
( cd ; cvmfs_server abort -f ; ) ;
return 1
fi
$CMSPKG search cms+cmssw+ | awk '{print $1}' | sed 's#cms+cmssw+##g'
$CMSPKG search cms+cmssw-patch+ | awk '{print $1}' | sed 's#cms+cmssw-patch+##g'
( cd ; cvmfs_server abort -f ; ) ;
return 0
}
function list_announced_arch_cmssws () {
ARCH=$1
#a_cmssws=$(wget --no-check-certificate -q -O- "${release_tag_xml}&architecture=$ARCH" | grep "<project" | grep "Announced" | cut -d\" -f2 | sort -u)
#a_cmssws=$(wget --no-check-certificate -q -O- "${releases_map}" | grep "$ARCH" | grep label=CMSSW_ | cut -d\; -f2 | cut -d= -f2)
a_cmssws=$(cat "$releases_map_local" | grep "$ARCH" | grep label=CMSSW_ | cut -d\; -f2 | cut -d= -f2)
r_cmssws=$(list_requested_arch_cmssws | grep "$ARCH" | awk '{print $NF}')
for the_cmssw in $a_cmssws $r_cmssws ; do
echo $the_cmssw
done | grep -v CMSSW_[0-9]_[0-9]_X$ | sort -u
return 0
}
function list_osx_cmssws () {
ARCH=$1
a_cmssws=$(wget --no-check-certificate -q -O- "$rpms_list/$ARCH" | grep osx[0-9] | grep "cms+cmssw+CMSSW\|cms+cmssw-patch+CMSSW" | sed "s#href=#|#g" | cut -d\| -f2 | sed "s#osx#|#g" | cut -d\| -f1 | cut -d+ -f3 | sed "s#-[0-9]# #g" | awk '{print $1}' | sort -u)
for cmssw in $a_cmssws ; do
for cmssw_excluded in $osx_cmssws_excluded ; do
echo "+"${cmssw_excluded}"+"
done | grep -q "+"${cmssw}"+"
[ $? -eq 0 ] && continue
echo $cmssw
done
return 0
}
function collect_arch_rpms_page () {
# to be executed only once at each execution of the script to create arch rpms page files
a_archs=$(wget --no-check-certificate -q -O- "$rpms_list" | grep slc[0-9]_ | grep amd | sed "s#/</a>#|#g" | sed "s#slc#|slc#g" | cut -d\| -f3 | sort -u)
for a in $a_archs ; do
echo "$a" | grep -q "$which_slc"
[ $? -eq 0 ] && continue
echo INFO downloading rpm list for $a to ${dev_arch_rpm_list}.${a}.txt
wget --no-check-certificate -q $rpms_list/${a} -O ${dev_arch_rpm_list}.${a}.txt
echo INFO downloaded rpm list for $a
#cat ${dev_arch_rpm_list}.${a}.txt
done
return 0
}
function install_cmssw_power_archs () {