source: trunk/MagicSoft/Mars/datacenter/scripts/sourcefile@ 7907

Last change on this file since 7907 was 7907, checked in by Daniela Dorner, 18 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 5.8 KB
Line 
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# Only constant variables are stored here, changing variables are stored
30# in datacenter/scripts/setup
31#
32
33source `dirname $0`/setup
34
35mars=`dirname $0 | sed -e 's/\/datacenter\/scripts//'`
36macrospath=$mars/datacenter/macros
37scriptspath=$mars/datacenter/scripts
38
39webpath=/www/htdocs/datacenter
40
41datetime=`date +%F-%H-%M-%S`
42
43check="ok"
44
45#failed codes
46#sequence build status
47Fbuildsequ=1
48Fdoexcl=2
49#run process status
50Ftimecorr=3
51Ffillraw=4
52Fsinope=5
53Ffillsinope=6
54Fresetexcl=7
55#sequence process status
56Fwritesequfile=8
57Ffilesavail=9
58Fnoccfile=10
59Fnocacofile=11
60Fmerppcc=12
61Fmerppcaco=13
62Fcallisto=14
63Ffillcalib=15
64Ffillsignal=16
65Fstar=17
66Ffillstar=18
67#dataset process status
68Fstardone=19
69Fganymed=20
70Ffillganymed=21
71
72# setup for jobmanager
73steps=$mars/steps.rc
74
75pno=0
76pnototal=0
77running=0
78queued=0
79runningscript=0
80queuedscript=0
81
82
83function setzero()
84{
85 val=$@
86 if [ "$val" == "" ]
87 then
88 test=`condor_q -global`
89 if [ "$test" == "" ]
90 then
91 echo $max
92 else
93 echo 0
94 fi
95 else
96 echo $val
97 fi
98}
99
100
101
102
103# in the following the function, which are needed by several scripts, are
104# defined
105
106# function to exit a script properly
107function finish()
108{
109 rm -v $todofile
110 rm -v $lockfile
111 date
112 exit
113}
114
115# function to make sure that a directory is made
116function makedir()
117{
118 if [ ! -d $@ ]
119 then
120 mkdir -pv $@
121 if [ ! -d $@ ]
122 then
123 echo "could not make dir "$@
124 finish
125 fi
126 fi
127}
128
129# function to check if a process is already locked
130function checklock()
131{
132 date > $lockfile
133 checklock0=$?
134 case $checklock0 in
135 0) echo "checklock0=$checklock0 -> continue " ;;
136 1) echo "checklock0=$checklock0 -> file $lockfile exists "
137 echo "-> $@ $program is running -> exit"
138 date
139 exit;;
140 *) echo "checklock0=$checklock0 -> something went completely wrong" ;;
141 esac
142}
143
144# function calling the macro, which is producing the todo-list
145function getdolist()
146{
147 datetime=`date +%F-%H-%M-%S`
148 year=`date +%Y`
149 date=NULL
150
151 getstatuslogpath=$logpath/getstatus/$program/$year
152 getstatuslog=$getstatuslogpath/getstatus-$table-$column-$datetime.log
153 makedir $getstatuslogpath
154
155 # get todo list
156 echo "getting todo list..."
157 check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
158
159 case $check0 in
160 1) echo "check0=$check0 -> everything ok, got todo list -> run $program";;
161 *) echo "check0=$check0 -> ERROR -> could not get todo list -> exit"
162 finish ;;
163 esac
164
165}
166
167function resetstatusvalues()
168{
169 statustime=NULL
170 starttime=NULL
171 returncode=NULL
172 failedcode=NULL
173 failedcodeadd=NULL
174 failedtime=NULL
175}
176
177function printstatusvalues()
178{
179 echo "the current values are:"
180 echo " statustime=$statustime"
181 echo " starttime=$starttime"
182 echo " returncode=$returncode"
183 echo " failedcode=$failedcode"
184 echo " failedcodeadd=$failedcodeadd"
185 echo " failedtime=$failedtime"
186 echo "-- check: -$check-"
187 echo ""
188}
189
190# function calling the macro to set the status, after a process has finished
191function setstatus()
192{
193 # set status values
194 resetstatusvalues
195 case $@ in
196 start) echo "start"
197 starttime="Now()"
198 ;;
199 stop) echo "stop"
200 case $check in
201 ok) echo " ok"
202 statustime="Now()"
203 ;;
204 no) echo "nothing new"
205 check="ok"
206 ;;
207 *) echo " failed"
208 starttime=noreset
209 returncode=$check
210 failedcode=$com
211 if ! [ "$comadd" = "" ]
212 then
213 failedcodeadd=$comadd
214 fi
215 failedtime="Now()"
216 check="ok"
217 ;;
218 esac
219 ;;
220 *) echo "error -> exit"
221 exit
222 ;;
223 esac
224
225# printstatusvalues
226 # set status
227 setstatuslogpath=$logpath/setstatus/$program/$var1
228 makedir $setstatuslogpath
229 setstatuslog=$setstatuslogpath/setstatus-$@-$program-$var2.log
230 checkstatus=`root -q -b $macrospath/setstatus.C+\("\"$var2\""\,"\"$table\""\,"\"$column\""\,"\"$statustime\""\,"\"$returncode\""\,"\"$failedcode\""\,"\"$failedcodeadd\""\,"\"$starttime\""\,"\"$failedtime\""\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
231 case $checkstatus in
232 1) echo "checkstatus=$checkstatus -> everything ok, status has been set";;
233 *) echo "checkstatus=$checkstatus -> ERROR -> step could not be set -> exit"
234 finish ;;
235 esac
236}
237
238
239
Note: See TracBrowser for help on using the repository browser.