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-2006
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | # This script launches the writing of the sequence files for all sequences
|
---|
28 | # for which this step is needed.
|
---|
29 | #
|
---|
30 | # After checking, if the script is already running, the todolist is
|
---|
31 | # written by using the macro getdolist.C
|
---|
32 | # Then the sequence file is written for each sequence in the todolist using
|
---|
33 | # the macro writesequencefile.C
|
---|
34 | # If this was successful, the status is inserted into the database using
|
---|
35 | # the macro setstatus.C
|
---|
36 | #
|
---|
37 |
|
---|
38 | user=`whoami`
|
---|
39 | program=writesequencefile
|
---|
40 | source /home/$user/Mars/datacenter/scripts/sourcefile
|
---|
41 |
|
---|
42 | set -C
|
---|
43 |
|
---|
44 | table=SequenceProcessStatus
|
---|
45 | column=fSequenceFileWritten
|
---|
46 | date=NULL
|
---|
47 | datetime=`date +%F-%H-%M-%S`
|
---|
48 | year=`date +%Y`
|
---|
49 |
|
---|
50 | todofile=$listpath/ToDo-$table-$column.txt
|
---|
51 | getstatuslogpath=$logpath/getstatus/$program/$year
|
---|
52 | getstatuslog=$getstatuslogpath/getstatus-$program-$datetime.log
|
---|
53 |
|
---|
54 | scriptlogpath=$logpath/run/$program/`date +%Y/%m/%d`
|
---|
55 | makedir $scriptlogpath
|
---|
56 | scriptlog=$scriptlogpath/run$program-$datetime.log
|
---|
57 |
|
---|
58 | date >> $scriptlog 2>&1
|
---|
59 |
|
---|
60 | makedir $getstatuslogpath >> $scriptlog 2>&1
|
---|
61 |
|
---|
62 | cd $mars
|
---|
63 |
|
---|
64 | # check if script is already running
|
---|
65 | date > $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
|
---|
66 | checklock0=$?
|
---|
67 | case $checklock0 in
|
---|
68 | 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
|
---|
69 | 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
|
---|
70 | echo "-> $program is running -> exit" >> $scriptlog 2>&1
|
---|
71 | date >> $scriptlog 2>&1
|
---|
72 | exit;;
|
---|
73 | *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
|
---|
74 | esac
|
---|
75 |
|
---|
76 | # get todo list
|
---|
77 | echo "getting list..." >> $scriptlog 2>&1
|
---|
78 | check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
|
---|
79 |
|
---|
80 | case $check0 in
|
---|
81 | 1) echo "check0=$check0 -> everything ok -> run $program" >> $scriptlog 2>&1;;
|
---|
82 | *) echo "check0=$check0 -> ERROR -> could not get todo list -> exit" >> $scriptlog 2>&1
|
---|
83 | rm -v $todofile >> $scriptlog 2>&1
|
---|
84 | rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
|
---|
85 | date >> $scriptlog 2>&1
|
---|
86 | exit;;
|
---|
87 | esac
|
---|
88 |
|
---|
89 | # get sequences from todo file
|
---|
90 | sequences=(`cat $todofile`)
|
---|
91 | if [ "$sequences" = "" ]
|
---|
92 | then
|
---|
93 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
---|
94 | rm -v $todofile >> $scriptlog 2>&1
|
---|
95 | rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
|
---|
96 | date >> $scriptlog 2>&1
|
---|
97 | exit
|
---|
98 | fi
|
---|
99 |
|
---|
100 | # write sequence file for all sequences in todo file
|
---|
101 | echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
|
---|
102 | for sequence in ${sequences[@]}
|
---|
103 | do
|
---|
104 | no=`printf %08d $sequence | cut -c 0-4`
|
---|
105 | no2=`printf %08d $sequence`
|
---|
106 | sequencepath=$sequpath/$no
|
---|
107 | makedir $sequencepath >> $scriptlog 2>&1
|
---|
108 |
|
---|
109 | writesequencefilelogpath=$logpath/$program/$no
|
---|
110 | echo "$programlogpath: "$writesequencefilelogpath >> $scriptlog 2>&1
|
---|
111 | makedir $writesequencefilelogpath >> $scriptlog 2>&1
|
---|
112 |
|
---|
113 | echo "write sequencefile for sequence $sequence" >> $scriptlog 2>&1
|
---|
114 | check2=`root -q -b $macrospath/writesequencefile.C+\($sequence\,"\"$sequpath\""\) | tee $writesequencefilelogpath/writesequencefile-$no2.log | grep int | sed -e 's/(int)//'`
|
---|
115 | case $check2 in
|
---|
116 | 1) echo "check2=$check2 -> everything ok " >> $scriptlog 2>&1
|
---|
117 | echo "-> inserting the status for $program for sequence $sequence into the db" >> $scriptlog 2>&1
|
---|
118 | statustime="Now()"
|
---|
119 | failed="NULL"
|
---|
120 | starttime="NULL"
|
---|
121 | failedtime="NULL"
|
---|
122 | var1=$no
|
---|
123 | var2=$no2
|
---|
124 | setstatus
|
---|
125 | ;;
|
---|
126 | *) echo "check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
---|
127 | esac
|
---|
128 | done
|
---|
129 |
|
---|
130 | rm -v $todofile >> $scriptlog 2>&1
|
---|
131 | rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
|
---|
132 |
|
---|
133 | set +C
|
---|
134 |
|
---|
135 | date >> $scriptlog 2>&1
|
---|
136 |
|
---|