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 05/2005 <mailto:dorner@astro.uni-wuerzburg.de>
|
---|
21 | #
|
---|
22 | # Copyright: MAGIC Software Development, 2000-2006
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | # This a resource file for the scripts, in which the standard paths and
|
---|
28 | # functions, which are needed more often are stored.
|
---|
29 | #
|
---|
30 |
|
---|
31 | export ROOTSYS=/opt/root_v4.04.02g
|
---|
32 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROOTSYS/lib
|
---|
33 | export PATH=$PATH:$ROOTSYS/bin
|
---|
34 |
|
---|
35 | mars=/home/operator/Mars
|
---|
36 | macrospath=$mars/datacenter/macros
|
---|
37 | scriptspath=$mars/datacenter/scripts
|
---|
38 |
|
---|
39 | logpath=/magic/datacenter/autologs
|
---|
40 | lockpath=/magic/datacenter/locks
|
---|
41 | listpath=/magic/datacenter/lists
|
---|
42 | setuppath=/magic/datacenter/setup
|
---|
43 |
|
---|
44 | datapath=/magic/data
|
---|
45 | subsystempath=/magic/subsystemdata
|
---|
46 | sequpath=/magic/sequences
|
---|
47 | datasetpath=/magic/datasets
|
---|
48 |
|
---|
49 | datetime=`date +%F-%H-%M-%S`
|
---|
50 |
|
---|
51 | check="ok"
|
---|
52 |
|
---|
53 |
|
---|
54 | #failed codes
|
---|
55 | #sequence build status
|
---|
56 | Fbuildsequ=1
|
---|
57 | Fdoexcl=2
|
---|
58 | #run process status
|
---|
59 | Ftimecorr=3
|
---|
60 | Ffillraw=4
|
---|
61 | Fsinope=5
|
---|
62 | Ffillsinope=6
|
---|
63 | Fresetexcl=7
|
---|
64 | #sequence process status
|
---|
65 | Fwritesequfile=8
|
---|
66 | Ffilesavail=9
|
---|
67 | Fnoccfile=10
|
---|
68 | Fnocacofile=11
|
---|
69 | Fmerppcc=12
|
---|
70 | Fmerppcaco=13
|
---|
71 | Fcallisto=14
|
---|
72 | Ffillcalib=15
|
---|
73 | Ffillsignal=16
|
---|
74 | Fstar=17
|
---|
75 | Ffillstar=18
|
---|
76 | #dataset process status
|
---|
77 | Fstardone=19
|
---|
78 | Fganymed=20
|
---|
79 | Ffillganymed=21
|
---|
80 |
|
---|
81 |
|
---|
82 |
|
---|
83 | function finish()
|
---|
84 | {
|
---|
85 | rm -v $todofile
|
---|
86 | rm -v $lockfile
|
---|
87 | date
|
---|
88 | exit
|
---|
89 | }
|
---|
90 |
|
---|
91 | function makedir()
|
---|
92 | {
|
---|
93 | if [ ! -d $@ ]
|
---|
94 | then
|
---|
95 | mkdir -pv $@
|
---|
96 | if [ ! -d $@ ]
|
---|
97 | then
|
---|
98 | echo "could not make dir "$@
|
---|
99 | finish
|
---|
100 | fi
|
---|
101 | fi
|
---|
102 | }
|
---|
103 |
|
---|
104 | function checklock()
|
---|
105 | {
|
---|
106 | date > $lockfile
|
---|
107 | checklock0=$?
|
---|
108 | case $checklock0 in
|
---|
109 | 0) echo "checklock0=$checklock0 -> continue " ;;
|
---|
110 | 1) echo "checklock0=$checklock0 -> file $lockfile exists "
|
---|
111 | echo "-> $@ $program is running -> exit"
|
---|
112 | date
|
---|
113 | exit;;
|
---|
114 | *) echo "checklock0=$checklock0 -> something went completely wrong" ;;
|
---|
115 | esac
|
---|
116 | }
|
---|
117 |
|
---|
118 | function getdolist()
|
---|
119 | {
|
---|
120 | datetime=`date +%F-%H-%M-%S`
|
---|
121 | year=`date +%Y`
|
---|
122 | date=NULL
|
---|
123 |
|
---|
124 | getstatuslogpath=$logpath/getstatus/$program/$year
|
---|
125 | getstatuslog=$getstatuslogpath/getstatus-$table-$column-$datetime.log
|
---|
126 | makedir $getstatuslogpath
|
---|
127 |
|
---|
128 | # get todo list
|
---|
129 | echo "getting todo list..."
|
---|
130 | check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
|
---|
131 |
|
---|
132 | case $check0 in
|
---|
133 | 1) echo "check0=$check0 -> everything ok, got todo list -> run $program";;
|
---|
134 | *) echo "check0=$check0 -> ERROR -> could not get todo list -> exit"
|
---|
135 | finish ;;
|
---|
136 | esac
|
---|
137 |
|
---|
138 | }
|
---|
139 |
|
---|
140 | function resetstatusvalues()
|
---|
141 | {
|
---|
142 | statustime=NULL
|
---|
143 | starttime=NULL
|
---|
144 | returncode=NULL
|
---|
145 | failedcode=NULL
|
---|
146 | failedcodeadd=NULL
|
---|
147 | failedtime=NULL
|
---|
148 | }
|
---|
149 |
|
---|
150 | function printstatusvalues()
|
---|
151 | {
|
---|
152 | echo "the current values are:"
|
---|
153 | echo " statustime=$statustime"
|
---|
154 | echo " starttime=$starttime"
|
---|
155 | echo " returncode=$returncode"
|
---|
156 | echo " failedcode=$failedcode"
|
---|
157 | echo " failedcodeadd=$failedcodeadd"
|
---|
158 | echo " failedtime=$failedtime"
|
---|
159 | echo "-- check: -$check-"
|
---|
160 | echo ""
|
---|
161 | }
|
---|
162 |
|
---|
163 | function setstatus()
|
---|
164 | {
|
---|
165 | # set status values
|
---|
166 | resetstatusvalues
|
---|
167 | case $@ in
|
---|
168 | start) echo "start"
|
---|
169 | starttime="Now()"
|
---|
170 | ;;
|
---|
171 | stop) echo "stop"
|
---|
172 | case $check in
|
---|
173 | ok) echo " ok"
|
---|
174 | statustime="Now()"
|
---|
175 | ;;
|
---|
176 | no) echo "nothing new"
|
---|
177 | check="ok"
|
---|
178 | ;;
|
---|
179 | *) echo " failed"
|
---|
180 | starttime=noreset
|
---|
181 | returncode=$check
|
---|
182 | failedcode=$com
|
---|
183 | if ! [ "$comadd" = "" ]
|
---|
184 | then
|
---|
185 | failedcodeadd=$comadd
|
---|
186 | fi
|
---|
187 | failedtime="Now()"
|
---|
188 | check="ok"
|
---|
189 | ;;
|
---|
190 | esac
|
---|
191 | ;;
|
---|
192 | *) echo "error -> exit"
|
---|
193 | exit
|
---|
194 | ;;
|
---|
195 | esac
|
---|
196 |
|
---|
197 | # printstatusvalues
|
---|
198 | # set status
|
---|
199 | setstatuslogpath=$logpath/setstatus/$program/$var1
|
---|
200 | makedir $setstatuslogpath
|
---|
201 | setstatuslog=$setstatuslogpath/setstatus-$@-$program-$var2.log
|
---|
202 | checkstatus=`root -q -b $macrospath/setstatus.C+\("\"$var2\""\,"\"$table\""\,"\"$column\""\,"\"$statustime\""\,"\"$returncode\""\,"\"$failedcode\""\,"\"$failedcodeadd\""\,"\"$starttime\""\,"\"$failedtime\""\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
|
---|
203 | case $checkstatus in
|
---|
204 | 1) echo "checkstatus=$checkstatus -> everything ok, status has been set";;
|
---|
205 | *) echo "checkstatus=$checkstatus -> ERROR -> step could not be set -> exit"
|
---|
206 | finish ;;
|
---|
207 | esac
|
---|
208 | }
|
---|
209 |
|
---|
210 |
|
---|
211 |
|
---|