source: trunk/MagicSoft/Mars/datacenter/scripts/buildsequenceentries@ 6940

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