source: trunk/MagicSoft/Mars/datacenter/scripts/doexclusions@ 7106

Last change on this file since 7106 was 7106, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.5 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 08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
21#
22# Copyright: MAGIC Software Development, 2000-2004
23#
24#
25# ========================================================================
26#
27#
28
29source /home/operator/Mars/datacenter/scripts/sourcefile
30
31set -C
32
33cd $mars
34
35table=SequenceBuildStatus
36column=fExclusionsDone
37date=NULL
38datetime=`date +%F-%H-%M-%S`
39year=`date +%Y`
40
41todofile=$listpath/ToDo-$table-$column.txt
42getstatuslogpath=$logpath/getstatus/doexclusions/$year
43getstatuslog=$getstatuslogpath/getstatus-doexcludions-$datetime.log
44
45scriptlogpath=$logpath/run/doexclusions/`date +%Y/%m`
46if [ ! -d $scriptlogpath ]
47then
48 mkdir -pv $scriptlogpath
49 if [ ! -d $scriptlogpath ]
50 then
51 echo "could not make scriptlogpath "$scriptlogpath
52 exit
53 fi
54fi
55
56scriptlog=$scriptlogpath/doexclusions-$datetime.log
57
58date >> $scriptlog 2>&1
59
60if [ ! -d $getstatuslogpath ]
61then
62 mkdir -pv $getstatuslogpath >> $scriptlog 2>&1
63 if [ ! -d $getstatuslogpath ]
64 then
65 echo "could not make getstatuslogpath "$getstatuslogpath >> $scriptlog 2>&1
66 date >> $scriptlog 2>&1
67 exit
68 fi
69fi
70
71date > $lockpath/lock-doexclusions.txt >> $scriptlog 2>&1
72checklock0=$?
73case $checklock0 in
74 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
75 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
76 echo "-> getting list for callisto is running -> exit" >> $scriptlog 2>&1
77 date >> $scriptlog 2>&1
78 exit;;
79 *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
80esac
81
82
83echo "getting list..." >> $scriptlog 2>&1
84check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
85
86case $check0 in
87 1) echo "check0=$check0 -> everthing ok -> do step" >> $scriptlog 2>&1;;
88 *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
89esac
90
91dates=(`cat $todofile`)
92
93if [ "$dates" = "" ]
94then
95 echo "nothing to do -> exit" >> $scriptlog 2>&1
96 rm -v $todofile >> $scriptlog 2>&1
97 rm -v $lockpath/lock-doexclusions.txt >> $scriptlog 2>&1
98 date >> $scriptlog 2>&1
99 exit
100fi
101
102echo "dates: "${dates[@]} >> $scriptlog 2>&1
103
104for date in ${dates[@]}
105do
106 echo "do exclusions for date "$date
107 year2=`echo $date | cut -c 1-4`
108 doexclusionspath=$logpath/doexclusions/$year2
109 if [ ! -d $doexclusionspath ]
110 then
111 mkdir -pv $doexclusionspath >> $scriptlog 2>&1
112 if [ ! -d $doexclusionspath ]
113 then
114 echo "could not make doexclusionspath "$doexclusionspath >> $scriptlog 2>&1
115 continue
116 fi
117 fi
118 check1=`root -q -b $macrospath/doexclusions.C+\("\"$date\""\) | tee $doexclusionspath/doexclusions-$date.log | grep int | sed -e 's/(int)//'`
119
120 case $check1 in
121 1) echo "check1=1 -> everthing ok -> setting status..."
122 setstatuslogpath=$logpath/setstatus/doexclusions/$year2
123 if [ ! -d $setstatuslogpath ]
124 then
125 mkdir -pv $setstatuslogpath >> $scriptlog 2>&1
126 if [ ! -d $setstatuslogpath ]
127 then
128 echo "could not make setstatuslogpath "$setstatuslogpath >> $scriptlog 2>&1
129 continue
130 fi
131 fi
132 check2=`root -q -b $macrospath/setstatus.C+\("\"$date\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslogpath/setstatus-doexclusions-$date.log | grep int | sed -e 's/(int)//'`
133 case $check2 in
134 1) echo "check2=$check2 -> everthing ok, status has been set";;
135 *) echo "check2=$check2 -> ERROR -> step could not be set";;
136 esac
137 ;;
138 *) echo "check1=$check1 -> ERROR -> step has to be repeated";;
139 esac
140done
141
142rm -v $todofile >> $scriptlog 2>&1
143rm -v $lockpath/lock-doexclusions.txt >> $scriptlog 2>&1
144
145set +C
146
147date >> $scriptlog 2>&1
148
Note: See TracBrowser for help on using the repository browser.