1 | #!/bin/sh
|
---|
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): Daniela Dorner 08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
|
---|
21 | #
|
---|
22 | # Copyright: MAGIC Software Development, 2000-2004
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | #
|
---|
28 |
|
---|
29 | source /home/operator/Mars/datacenter/scripts/sourcefile
|
---|
30 |
|
---|
31 | table=DataSetProcessStatus
|
---|
32 | column=fStarFilesAvail
|
---|
33 | date=NULL
|
---|
34 | datetime=`date +%F-%H-%M-%S`
|
---|
35 | year=`date +%Y`
|
---|
36 |
|
---|
37 | todofile=/magic/datacenter/lists/ToDo-$table-$column.txt
|
---|
38 | getstatuslogpath=$logpath/getstatus/checkstardone/$year
|
---|
39 | getstatuslog=$getstatuslogpath/getstatus-$table-$column-$datetime.log
|
---|
40 |
|
---|
41 | scriptlogpath=$logpath/run/checkstardone/`date +%Y/%m/%d`
|
---|
42 | if [ ! -d $scriptlogpath ]
|
---|
43 | then
|
---|
44 | mkdir -pv $scriptlogpath
|
---|
45 | if [ ! -d $scriptlogpath ]
|
---|
46 | then
|
---|
47 | echo "could not make scriptlogpath "$scriptlogpath
|
---|
48 | exit
|
---|
49 | fi
|
---|
50 | fi
|
---|
51 |
|
---|
52 | scriptlog=$scriptlogpath/checkstardone-$datetime.log
|
---|
53 |
|
---|
54 | date >> $scriptlog 2>&1
|
---|
55 |
|
---|
56 | if [ ! -d $getstatuslogpath ]
|
---|
57 | then
|
---|
58 | mkdir -pv $getstatuslogpath >> $scriptlog 2>&1
|
---|
59 | if [ ! -d $getstatuslogpath ]
|
---|
60 | then
|
---|
61 | echo "could not make getstatuslogpath "$getstatuslogpath >> $scriptlog 2>&1
|
---|
62 | exit
|
---|
63 | fi
|
---|
64 | fi
|
---|
65 |
|
---|
66 | cd $mars
|
---|
67 |
|
---|
68 |
|
---|
69 | if [ -e $todofile ]
|
---|
70 | then
|
---|
71 | echo "checkstardone is already running -> exit" >> $scriptlog 2>&1
|
---|
72 | exit
|
---|
73 | fi
|
---|
74 |
|
---|
75 | echo "getting list..." >> $scriptlog 2>&1
|
---|
76 | check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
|
---|
77 |
|
---|
78 | case $check0 in
|
---|
79 | 1) echo "check0=$check0 -> everthing ok -> do step" >> $scriptlog 2>&1 ;;
|
---|
80 | *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1 ;;
|
---|
81 | esac
|
---|
82 |
|
---|
83 | datasets=(`cat $todofile`)
|
---|
84 |
|
---|
85 | if [ "$datasets" = "" ]
|
---|
86 | then
|
---|
87 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
---|
88 | rm -v $todofile >> $scriptlog 2>&1
|
---|
89 | rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
|
---|
90 | date >> $scriptlog 2>&1
|
---|
91 | exit
|
---|
92 | fi
|
---|
93 |
|
---|
94 | echo "datasets: "${datasets[@]} #>> $scriptlog 2>&1
|
---|
95 |
|
---|
96 | for dataset in ${datasets[@]}
|
---|
97 | do
|
---|
98 | no=`printf %08d $dataset | cut -c 0-4`
|
---|
99 | echo "checking files for dataset $dataset..." >> $scriptlog 2>&1
|
---|
100 | datasetfile=/magic/datasets/$no/dataset`printf %08d $dataset`.txt
|
---|
101 | sequences=(`cat $datasetfile | grep Sequences | sed -e 's/SequencesOn://g' | sed -e 's/SequencesOff://g'`)
|
---|
102 |
|
---|
103 | echo "sequences: "${sequences[@]}
|
---|
104 |
|
---|
105 | outpath=$logpath/checkstardone/$no
|
---|
106 | echo "outpath: "$outpath >> $scriptlog 2>&1
|
---|
107 | if [ ! -d $outpath ]
|
---|
108 | then
|
---|
109 | mkdir -pv $outpath >> $scriptlog 2>&1
|
---|
110 | if [ ! -d $outpath ]
|
---|
111 | then
|
---|
112 | echo "could not make outpath $outpath -> continue " >> $scriptlog 2>&1
|
---|
113 | continue
|
---|
114 | fi
|
---|
115 | fi
|
---|
116 |
|
---|
117 | for sequence in ${sequences[@]}
|
---|
118 | do
|
---|
119 | check1=`root -q -b $macrospath/checkstardone.C+\(\""$sequence\""\) | tee $outpath/checkstardone-$sequence.log | grep int | sed -e 's/(int)//'`
|
---|
120 |
|
---|
121 | case $check1 in
|
---|
122 | 1) echo "check1=$check1 -> everthing ok -> continue with next sequence..." >> $scriptlog 2>&1 ;;
|
---|
123 | *) echo "check1=$check1 -> ERROR " >> $scriptlog 2>&1
|
---|
124 | echo "starfiles not available for sequence -> continue" >> $scriptlog 2>&1
|
---|
125 | continue 2
|
---|
126 | ;;
|
---|
127 | esac
|
---|
128 | done
|
---|
129 |
|
---|
130 | setstatuslogpath=$logpath/setstatus/checkstardone/$no
|
---|
131 | if [ ! -d $setstatuslogpath ]
|
---|
132 | then
|
---|
133 | mkdir -pv $setstatuslogpath >> $scriptlog 2>&1
|
---|
134 | if [ ! -d $setstatuslogpath ]
|
---|
135 | then
|
---|
136 | echo "could not make setstatuslogpath "$setstatuslogpath >> $scriptlog 2>&1
|
---|
137 | continue
|
---|
138 | fi
|
---|
139 | fi
|
---|
140 | check2=`root -q -b $macrospath/setstatus.C+\("\"$dataset\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslogpath/setstatus-checkstardone-$dataset.log | grep int | sed -e 's/(int)//'`
|
---|
141 | case $check2 in
|
---|
142 | 1) echo "check2=$check2 -> everthing ok, status has been set" >> $scriptlog 2>&1 ;;
|
---|
143 | *) echo "check2=$check2 -> ERROR -> step could not be set" >> $scriptlog 2>&1 ;;
|
---|
144 | esac
|
---|
145 | done
|
---|
146 |
|
---|
147 | rm -v $todofile >> $scriptlog 2>&1
|
---|
148 | rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
|
---|
149 |
|
---|
150 | date >> $scriptlog 2>&1
|
---|
151 |
|
---|