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 | table=SequenceProcessStatus
|
---|
33 | column=fAllFilesAvail
|
---|
34 | date=NULL
|
---|
35 | datetime=`date +%F-%H-%M-%S`
|
---|
36 | year=`date +%Y`
|
---|
37 |
|
---|
38 | todofile=$listpath/ToDo-$table-$column.txt
|
---|
39 | getstatuslogpath=$logpath/getstatus/checkfileavail/$year
|
---|
40 | getstatuslog=$getstatuslogpath/getstatus-$table-$column-$datetime.log
|
---|
41 |
|
---|
42 | scriptlogpath=$logpath/run/checkfilesavail/`date +%Y/%m/%d`
|
---|
43 | if [ ! -d $scriptlogpath ]
|
---|
44 | then
|
---|
45 | mkdir -pv $scriptlogpath
|
---|
46 | if [ ! -d $scriptlogpath ]
|
---|
47 | then
|
---|
48 | echo "could not make scriptlogpath "$scriptlogpath
|
---|
49 | exit
|
---|
50 | fi
|
---|
51 | fi
|
---|
52 |
|
---|
53 | scriptlog=$scriptlogpath/checkfilesforsequenceavail-$datetime.log
|
---|
54 |
|
---|
55 | date >> $scriptlog 2>&1
|
---|
56 |
|
---|
57 | if [ ! -d $getstatuslogpath ]
|
---|
58 | then
|
---|
59 | mkdir -pv $getstatuslogpath >> $scriptlog 2>&1
|
---|
60 | if [ ! -d $getstatuslogpath ]
|
---|
61 | then
|
---|
62 | echo "could not make getstatuslogpath "$getstatuslogpath >> $scriptlog 2>&1
|
---|
63 | exit
|
---|
64 | fi
|
---|
65 | fi
|
---|
66 |
|
---|
67 | cd $mars
|
---|
68 |
|
---|
69 | if [ -e $todofile ]
|
---|
70 | then
|
---|
71 | echo "checkfilesforsequenceavail 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 | sequences=(`cat $todofile`)
|
---|
84 |
|
---|
85 | if [ "$sequences" = "" ]
|
---|
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 "sequences: "${sequences[@]} >> $scriptlog 2>&1
|
---|
95 |
|
---|
96 | for sequence in ${sequences[@]}
|
---|
97 | do
|
---|
98 | echo "checking files for sequence $sequence..." >> $scriptlog 2>&1
|
---|
99 | no=`printf %08d $sequence | cut -c 0-4`
|
---|
100 | outpath=$logpath/checkfileavail/$no
|
---|
101 | echo "outpath: "$outpath >> $scriptlog 2>&1
|
---|
102 | if [ ! -d $outpath ]
|
---|
103 | then
|
---|
104 | mkdir -pv $outpath >> $scriptlog 2>&1
|
---|
105 | if [ ! -d $outpath ]
|
---|
106 | then
|
---|
107 | echo "could not make outpath $outpath -> continue " >> $scriptlog 2>&1
|
---|
108 | continue
|
---|
109 | fi
|
---|
110 | fi
|
---|
111 | check1=`root -q -b $macrospath/checkfileavail.C+\(\""$sequence\""\) | tee $outpath/checkfileavail-$sequence.log | grep int | sed -e 's/(int)//'`
|
---|
112 |
|
---|
113 | case $check1 in
|
---|
114 | 1) echo "check1=$check1 -> everthing ok -> setting status..." >> $scriptlog 2>&1
|
---|
115 | setstatuslogpath=$logpath/setstatus/checkfileavail/$no
|
---|
116 | if [ ! -d $setstatuslogpath ]
|
---|
117 | then
|
---|
118 | mkdir -pv $setstatuslogpath >> $scriptlog 2>&1
|
---|
119 | if [ ! -d $setstatuslogpath ]
|
---|
120 | then
|
---|
121 | echo "could not make setstatuslogpath "$setstatuslogpath >> $scriptlog 2>&1
|
---|
122 | continue
|
---|
123 | fi
|
---|
124 | fi
|
---|
125 | check2=`root -q -b $macrospath/setstatus.C+\("\"$sequence\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslogpath/setstatus-checkfileavail-$sequence.log | grep int | sed -e 's/(int)//'`
|
---|
126 | case $check2 in
|
---|
127 | 1) echo "check2=$check2 -> everthing ok, status has been set" >> $scriptlog 2>&1 ;;
|
---|
128 | *) echo "check2=$check2 -> ERROR -> step could not be set" >> $scriptlog 2>&1 ;;
|
---|
129 | esac
|
---|
130 | ;;
|
---|
131 | *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1 ;;
|
---|
132 | esac
|
---|
133 | done
|
---|
134 |
|
---|
135 | rm -v $todofile >> $scriptlog 2>&1
|
---|
136 | rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
|
---|
137 |
|
---|
138 | date >> $scriptlog 2>&1
|
---|
139 |
|
---|