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

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