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 | user=`whoami`
|
---|
30 | source /home/$user/Mars/datacenter/scripts/sourcefile
|
---|
31 |
|
---|
32 | set -C
|
---|
33 |
|
---|
34 | table=DataSetProcessStatus
|
---|
35 | column=fGanymed
|
---|
36 | date=NULL
|
---|
37 | datetime=`date +%F-%H-%M-%S`
|
---|
38 | year=`date +%Y`
|
---|
39 | #pno=24 # number of processes, i.e. number of todo-files
|
---|
40 |
|
---|
41 | todofile=$listpath/ToDo-$table-$column
|
---|
42 | getstatuslogpath=$logpath/getstatus/ganymed/$year
|
---|
43 | getstatuslog=$getstatuslogpath/getstatus-ganymed-$datetime.log
|
---|
44 |
|
---|
45 | scriptlogpath=$logpath/run/ganymed/`date +%Y/%m/%d`
|
---|
46 | makedir $scriptlogpath
|
---|
47 |
|
---|
48 | scriptlog=$scriptlogpath/runganymed-$datetime.log
|
---|
49 |
|
---|
50 | date >> $scriptlog 2>&1
|
---|
51 |
|
---|
52 | makedir $getstatuslogpath >> $scriptlog 2>&1
|
---|
53 |
|
---|
54 | cd $mars
|
---|
55 |
|
---|
56 | date > $lockpath/lock-getting-ganymed-list.txt >> $scriptlog 2>&1
|
---|
57 | checklock0=$?
|
---|
58 | case $checklock0 in
|
---|
59 | 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
|
---|
60 | 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
|
---|
61 | echo "-> getting list for ganymed is running -> exit" >> $scriptlog 2>&1
|
---|
62 | date >> $scriptlog 2>&1
|
---|
63 | exit;;
|
---|
64 | *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
|
---|
65 | esac
|
---|
66 |
|
---|
67 | echo "checking if other todo-files are there" >> $scriptlog 2>&1
|
---|
68 | if ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
|
---|
69 | then
|
---|
70 | echo "other file(s) on disk " >> $scriptlog 2>&1
|
---|
71 | echo " -> choose one file and run ganymed" >> $scriptlog 2>&1
|
---|
72 | else
|
---|
73 | echo "getting list..." >> $scriptlog 2>&1
|
---|
74 | check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
|
---|
75 |
|
---|
76 | case $check0 in
|
---|
77 | 1) echo "check0=$check0 -> everything ok -> run ganymed" >> $scriptlog 2>&1;;
|
---|
78 | *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
---|
79 | esac
|
---|
80 | fi
|
---|
81 |
|
---|
82 | rm -v $lockpath/lock-getting-ganymed-list.txt >> $scriptlog 2>&1
|
---|
83 |
|
---|
84 | nr=bla
|
---|
85 | echo "finding the right todo-file" >> $scriptlog 2>&1
|
---|
86 | todofiles=`ls $listpath/ToDo-$table-$column-*`
|
---|
87 |
|
---|
88 | echo "todofiles: "${todofiles[@]} >> $scriptlog 2>&1
|
---|
89 |
|
---|
90 | for todofile in ${todofiles[@]}
|
---|
91 | do
|
---|
92 | if ! ls $todofile >> $scriptlog 2>&1
|
---|
93 | then
|
---|
94 | echo "file is not on disk -> continue" >> $scriptlog 2>&1
|
---|
95 | continue
|
---|
96 | fi
|
---|
97 | lockfile=`echo $todofile | sed -e 's/lists/locks/' -e 's/ToDo/lock/'`
|
---|
98 | date > $lockfile >> $scriptlog 2>&1
|
---|
99 | checklock=$?
|
---|
100 | case $checklock in
|
---|
101 | 0) echo "checklock=$checklock -> setting number" >> $scriptlog 2>&1
|
---|
102 | nr=${i}
|
---|
103 | break;;
|
---|
104 | 1) echo "checklock=$checklock -> file exists -> continue" >> $scriptlog 2>&1;;
|
---|
105 | *) echo "checklock=$checklock -> something went completely wrong" >> $scriptlog 2>&1;;
|
---|
106 | esac
|
---|
107 | done
|
---|
108 |
|
---|
109 | case $nr in
|
---|
110 | bla) echo "everything is beeing processed -> exit" >> $scriptlog 2>&1
|
---|
111 | date >> $scriptlog 2>&1
|
---|
112 | exit;;
|
---|
113 | 12345678) echo "process nr: "$nr >> $scriptlog 2>&1;;
|
---|
114 | esac
|
---|
115 |
|
---|
116 |
|
---|
117 | datasets=(`cat $todofile`)
|
---|
118 |
|
---|
119 | if [ "$datasets" = "" ]
|
---|
120 | then
|
---|
121 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
---|
122 | rm -v $todofile >> $scriptlog 2>&1
|
---|
123 | rm -v $lockfile >> $scriptlog 2>&1
|
---|
124 | date >> $scriptlog 2>&1
|
---|
125 | exit
|
---|
126 | fi
|
---|
127 |
|
---|
128 | echo "datasets: "${datasets[@]} >> $scriptlog 2>&1
|
---|
129 |
|
---|
130 | for dataset in ${datasets[@]}
|
---|
131 | do
|
---|
132 | no=`printf %08d $dataset | cut -c 0-5`
|
---|
133 | no2=`printf %08d $dataset`
|
---|
134 | outpath="$datapath/ganymed/$no/$no2"
|
---|
135 | echo "outpath: "$outpath >> $scriptlog 2>&1
|
---|
136 | makedir $outpath >> $scriptlog 2>&1
|
---|
137 |
|
---|
138 | datasetfile="$datasetpath/$no/dataset$no2.txt"
|
---|
139 | echo "datasetfile: "$datasetfile >> $scriptlog 2>&1
|
---|
140 | wobble=`grep 'WobbleMode:' $datasetfile` >> $scriptlog 2>&1
|
---|
141 | wobble2=`echo $wobble | grep ^\#` >> $scriptlog 2>&1
|
---|
142 | if [ "$wobble2" = "" ]
|
---|
143 | then
|
---|
144 | mode="wobble" >> $scriptlog 2>&1
|
---|
145 | else
|
---|
146 | mode="onoff" >> $scriptlog 2>&1
|
---|
147 | fi
|
---|
148 | ganymedrc=$setuppath/ganymed/ganymed_$mode.rc
|
---|
149 |
|
---|
150 | echo "run ganymed..." >> $scriptlog 2>&1
|
---|
151 | ./ganymed -b -q -v4 -f --sum --config=$ganymedrc --log=$outpath/ganymed$no2.log --html=$outpath/ganymed$no2.html --out=$outpath $datasetfile 2>> $scriptlog> /dev/null
|
---|
152 | check1=$?
|
---|
153 |
|
---|
154 | case $check1 in
|
---|
155 | 0) echo "check1=$check1 -> everything ok " >> $scriptlog 2>&1
|
---|
156 | echo "-> inserting the status for ganymed for dataset $dataset into the db" >> $scriptlog 2>&1
|
---|
157 | setstatuslogpath=$logpath/setstatus/ganymed/$no
|
---|
158 | makedir $setstatuslogpath >> $scriptlog 2>&1
|
---|
159 | setstatuslog=$setstatuslogpath/setstatus-ganymed-$no2.log
|
---|
160 |
|
---|
161 | check4=`root -q -b $macrospath/setstatus.C+\("\"$dataset\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
|
---|
162 | case $check4 in
|
---|
163 | 1) echo "check4=$check4 -> everything ok, status has been set" >> $scriptlog 2>&1;;
|
---|
164 | *) echo "check4=$check4 -> ERROR -> step could not be set" >> $scriptlog 2>&1;;
|
---|
165 | esac
|
---|
166 | ;;
|
---|
167 | *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
---|
168 | esac
|
---|
169 | done
|
---|
170 |
|
---|
171 | rm -v $todofile >> $scriptlog 2>&1
|
---|
172 | rm -v $lockfile >> $scriptlog 2>&1
|
---|
173 |
|
---|
174 | set +C
|
---|
175 |
|
---|
176 | date >> $scriptlog 2>&1
|
---|
177 |
|
---|