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=SequenceProcessStatus
|
---|
35 | column=fStar
|
---|
36 | date=NULL
|
---|
37 | datetime=`date +%F-%H-%M-%S`
|
---|
38 | year=`date +%Y`
|
---|
39 | #pno=500 # number of processes, i.e. number of todo-files
|
---|
40 |
|
---|
41 | todofile=$listpath/ToDo-$table-$column
|
---|
42 | getstatuslogpath=$logpath/getstatus/star/$year
|
---|
43 | getstatuslog=$getstatuslogpath/getstatus-star-$datetime.log
|
---|
44 |
|
---|
45 | scriptlogpath=$logpath/run/star/`date +%Y/%m/%d`
|
---|
46 | makedir $scriptlogpath
|
---|
47 | scriptlog=$scriptlogpath/runstar-$datetime.log
|
---|
48 |
|
---|
49 | date >> $scriptlog 2>&1
|
---|
50 |
|
---|
51 | makedir $getstatuslogpath >> $scriptlog 2>&1
|
---|
52 |
|
---|
53 | cd $mars
|
---|
54 |
|
---|
55 | date > $lockpath/lock-getting-star-list.txt >> $scriptlog 2>&1
|
---|
56 | checklock0=$?
|
---|
57 | case $checklock0 in
|
---|
58 | 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
|
---|
59 | 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
|
---|
60 | echo "-> getting list for star is running -> exit" >> $scriptlog 2>&1
|
---|
61 | date >> $scriptlog 2>&1
|
---|
62 | exit;;
|
---|
63 | *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
|
---|
64 | esac
|
---|
65 |
|
---|
66 | echo "checking if other todo-files are there" >> $scriptlog 2>&1
|
---|
67 | if ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
|
---|
68 | then
|
---|
69 | echo "other file(s) on disk " >> $scriptlog 2>&1
|
---|
70 | echo " -> choose one file and start calculation of image parameter" >> $scriptlog 2>&1
|
---|
71 | else
|
---|
72 | echo "getting list..." >> $scriptlog 2>&1
|
---|
73 | check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
|
---|
74 |
|
---|
75 | case $check0 in
|
---|
76 | 1) echo "check0=$check0 -> everything ok -> run star" >> $scriptlog 2>&1;;
|
---|
77 | *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
---|
78 | esac
|
---|
79 | fi
|
---|
80 |
|
---|
81 | rm -v $lockpath/lock-getting-star-list.txt >> $scriptlog 2>&1
|
---|
82 |
|
---|
83 | nr=bla
|
---|
84 | echo "finding the right todo-file" >> $scriptlog 2>&1
|
---|
85 | todofiles=`ls $listpath/ToDo-$table-$column-*`
|
---|
86 |
|
---|
87 | echo "todofiles: "${todofiles[@]} >> $scriptlog 2>&1
|
---|
88 |
|
---|
89 | for todofile in ${todofiles[@]}
|
---|
90 | do
|
---|
91 | if ! ls $todofile >> $scriptlog 2>&1
|
---|
92 | then
|
---|
93 | echo "file is not on disk -> continue" >> $scriptlog 2>&1
|
---|
94 | continue
|
---|
95 | fi
|
---|
96 | lockfile=`echo $todofile | sed -e 's/lists/locks/' -e 's/ToDo/lock/'`
|
---|
97 | date > $lockfile >> $scriptlog 2>&1
|
---|
98 | checklock=$?
|
---|
99 | case $checklock in
|
---|
100 | 0) echo "checklock=$checklock -> setting number" >> $scriptlog 2>&1
|
---|
101 | nr=${i}
|
---|
102 | break;;
|
---|
103 | 1) echo "checklock=$checklock -> file exists -> continue" >> $scriptlog 2>&1;;
|
---|
104 | *) echo "checklock=$checklock -> something went completely wrong" >> $scriptlog 2>&1;;
|
---|
105 | esac
|
---|
106 | done
|
---|
107 |
|
---|
108 | case $nr in
|
---|
109 | bla) echo "everything is beeing processed -> exit" >> $scriptlog 2>&1
|
---|
110 | date >> $scriptlog 2>&1
|
---|
111 | exit;;
|
---|
112 | 12345678) echo "process nr: "$nr >> $scriptlog 2>&1;;
|
---|
113 | esac
|
---|
114 |
|
---|
115 |
|
---|
116 | sequences=(`cat $todofile`)
|
---|
117 |
|
---|
118 | if [ "$sequences" = "" ]
|
---|
119 | then
|
---|
120 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
---|
121 | rm -v $todofile >> $scriptlog 2>&1
|
---|
122 | rm -v $lockfile >> $scriptlog 2>&1
|
---|
123 | date >> $scriptlog 2>&1
|
---|
124 | exit
|
---|
125 | fi
|
---|
126 |
|
---|
127 | echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
|
---|
128 |
|
---|
129 | for sequence in ${sequences[@]}
|
---|
130 | do
|
---|
131 | no=`printf %08d $sequence | cut -c 0-4`
|
---|
132 | no2=`printf %08d $sequence`
|
---|
133 | outpath="$datapath/star/$no/$no2"
|
---|
134 | inpath=`echo $outpath | sed -e 's/star/callisto/'`
|
---|
135 | echo "inpath: "$inpath >> $scriptlog 2>&1
|
---|
136 | echo "outpath: "$outpath >> $scriptlog 2>&1
|
---|
137 | makedir $outpath >> $scriptlog 2>&1
|
---|
138 |
|
---|
139 | sequfile="$sequpath/$no/sequence$no2.txt"
|
---|
140 | echo "sequfile: "$sequfile >> $scriptlog 2>&1
|
---|
141 |
|
---|
142 | echo "run star..." >> $scriptlog 2>&1
|
---|
143 | ./star -b -q -v4 -f --log=$outpath/star$no2.log --html=$outpath/star$no2.html --ind=$inpath --out=$outpath $sequfile 2>> $scriptlog> /dev/null
|
---|
144 | check1=$?
|
---|
145 |
|
---|
146 | case $check1 in
|
---|
147 | 0) echo "check1=$check1 -> everything ok " >> $scriptlog 2>&1
|
---|
148 | echo "-> inserting the status for star for sequence $sequence into the db" >> $scriptlog 2>&1
|
---|
149 | setstatuslogpath=$logpath/setstatus/star/$no
|
---|
150 | makedir $setstatuslogpath >> $scriptlog 2>&1
|
---|
151 | setstatuslog=$setstatuslogpath/setstatus-star-$no2.log
|
---|
152 |
|
---|
153 | check4=`root -q -b $macrospath/setstatus.C+\("\"$sequence\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
|
---|
154 | case $check4 in
|
---|
155 | 1) echo "check4=$check4 -> everything ok, status has been set" >> $scriptlog 2>&1;;
|
---|
156 | *) echo "check4=$check4 -> ERROR -> step could not be set" >> $scriptlog 2>&1;;
|
---|
157 | esac
|
---|
158 | ;;
|
---|
159 | *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
---|
160 | esac
|
---|
161 | done
|
---|
162 |
|
---|
163 | rm -v $todofile >> $scriptlog 2>&1
|
---|
164 | rm -v $lockfile >> $scriptlog 2>&1
|
---|
165 |
|
---|
166 | set +C
|
---|
167 |
|
---|
168 | date >> $scriptlog 2>&1
|
---|
169 |
|
---|