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=fFillGanymed
|
---|
36 | date=NULL
|
---|
37 | datetime=`date +%F-%H-%M-%S`
|
---|
38 | year=`date +%Y`
|
---|
39 |
|
---|
40 | todofile=$listpath/ToDo-$table-$column.txt
|
---|
41 | getstatuslogpath=$logpath/getstatus/fillganymws/$year
|
---|
42 | getstatuslog=$getstatuslogpath/getstatus-fillganymed-$datetime.log
|
---|
43 |
|
---|
44 | scriptlogpath=$logpath/run/fillganymed/`date +%Y/%m/%d`
|
---|
45 | makedir $scriptlogpath
|
---|
46 | scriptlog=$scriptlogpath/runfillganymed-$datetime.log
|
---|
47 |
|
---|
48 | date >> $scriptlog 2>&1
|
---|
49 |
|
---|
50 | makedir $getstatuslogpath >> $scriptlog 2>&1
|
---|
51 |
|
---|
52 | cd $mars
|
---|
53 |
|
---|
54 | date > $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
|
---|
55 | checklock0=$?
|
---|
56 | case $checklock0 in
|
---|
57 | 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
|
---|
58 | 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
|
---|
59 | echo "-> fillganymed is running -> exit" >> $scriptlog 2>&1
|
---|
60 | date >> $scriptlog 2>&1
|
---|
61 | exit;;
|
---|
62 | *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
|
---|
63 | esac
|
---|
64 |
|
---|
65 | echo "getting list..." >> $scriptlog 2>&1
|
---|
66 | check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
|
---|
67 |
|
---|
68 | case $check0 in
|
---|
69 | 1) echo "check0=$check0 -> everything ok -> run fillganymed" >> $scriptlog 2>&1;;
|
---|
70 | *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
---|
71 | esac
|
---|
72 |
|
---|
73 | datasets=(`cat $todofile`)
|
---|
74 |
|
---|
75 | if [ "$datasets" = "" ]
|
---|
76 | then
|
---|
77 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
---|
78 | rm -v $todofile >> $scriptlog 2>&1
|
---|
79 | rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
|
---|
80 | date >> $scriptlog 2>&1
|
---|
81 | exit
|
---|
82 | fi
|
---|
83 |
|
---|
84 | echo "datasets: "${datasets[@]} >> $scriptlog 2>&1
|
---|
85 |
|
---|
86 | for dataset in ${datasets[@]}
|
---|
87 | do
|
---|
88 | no=`printf %08d $dataset | cut -c 0-5`
|
---|
89 | no2=`printf %08d $dataset`
|
---|
90 | path="$datapath/ganymed/$no/$no2"
|
---|
91 | ganymedfile=$path/ganymed$no2.root
|
---|
92 | fillganymedlogpath=$logpath/fillganymed/$no
|
---|
93 | echo "fillganymedlogpath: "$fillganymedlogpath >> $scriptlog 2>&1
|
---|
94 | makedir $fillganymedlogpath >> $scriptlog 2>&1
|
---|
95 | fillganymedlog=$fillganymedlogpath/fillganymed-$dataset.log
|
---|
96 |
|
---|
97 | echo "run fillganymed for dataset $dataset" >> $scriptlog 2>&1
|
---|
98 | check2=`root -q -b $macrospath/fillganymed.C+\("\"$ganymedfile\""\,kFALSE\) | tee $fillganymedlog | grep int | sed -e 's/(int)//'`
|
---|
99 | case $check2 in
|
---|
100 | 1) echo "check2=$check2 -> everything ok " >> $scriptlog 2>&1
|
---|
101 | echo "-> inserting the status for fillganymed for dataset $dataset into the db" >> $scriptlog 2>&1
|
---|
102 | setstatuslogpath=$logpath/setstatus/fillganymed/$no
|
---|
103 | makedir $setstatuslogpath >> $scriptlog 2>&1
|
---|
104 | setstatuslog=$setstatuslogpath/setstatus-fillganymed-$no2.log
|
---|
105 |
|
---|
106 | check4=`root -q -b $macrospath/setstatus.C+\("\"$dataset\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
|
---|
107 | case $check4 in
|
---|
108 | 1) echo "check4=$check4 -> everything ok, status has been set" >> $scriptlog 2>&1;;
|
---|
109 | *) echo "check4=$check4 -> ERROR -> step could not be set" >> $scriptlog 2>&1;;
|
---|
110 | esac
|
---|
111 | ;;
|
---|
112 | *) echo "check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
---|
113 | esac
|
---|
114 | done
|
---|
115 |
|
---|
116 | rm -v $todofile >> $scriptlog 2>&1
|
---|
117 | rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
|
---|
118 |
|
---|
119 | set +C
|
---|
120 |
|
---|
121 | date >> $scriptlog 2>&1
|
---|
122 |
|
---|