| 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 | export ROOTSYS=/opt/root_v3.10.02
|
|---|
| 30 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROOTSYS/lib
|
|---|
| 31 | export PATH=$PATH:$ROOTSYS/bin
|
|---|
| 32 |
|
|---|
| 33 | set -C
|
|---|
| 34 |
|
|---|
| 35 | mars=/home/operator/Mars
|
|---|
| 36 | macrospath=$mars/datacenter/macros
|
|---|
| 37 | scriptspath=$mars/datacenter/scripts
|
|---|
| 38 |
|
|---|
| 39 | cd $mars
|
|---|
| 40 |
|
|---|
| 41 | table=SequenceBuildStatus
|
|---|
| 42 | column=fSequenceEntriesBuilt
|
|---|
| 43 | date=NULL
|
|---|
| 44 | datetime=`date +%F-%H-%M-%S`
|
|---|
| 45 | year=`date +%Y`
|
|---|
| 46 |
|
|---|
| 47 | todofile=/magic/datacenter/lists/ToDo-$table-$column.txt
|
|---|
| 48 | lockpath=/magic/datacenter/locks
|
|---|
| 49 | logpath=/magic/datacenter/autologs
|
|---|
| 50 | getstatuslogpath=$logpath/getstatus/buildsequenceentries/$year
|
|---|
| 51 | getstatuslog=$getstatuslogpath/getstatus-buildsequenceentries-$datetime.log
|
|---|
| 52 |
|
|---|
| 53 | scriptlogpath=$logpath/run/buildsequenceentries/`date +%Y/%m`
|
|---|
| 54 | if [ ! -d $scriptlogpath ]
|
|---|
| 55 | then
|
|---|
| 56 | mkdir -pv $scriptlogpath
|
|---|
| 57 | if [ ! -d $scriptlogpath ]
|
|---|
| 58 | then
|
|---|
| 59 | echo "could not make scriptlogpath "$scriptlogpath
|
|---|
| 60 | exit
|
|---|
| 61 | fi
|
|---|
| 62 | fi
|
|---|
| 63 |
|
|---|
| 64 | scriptlog=$scriptlogpath/buildsequenceentries-$datetime.log
|
|---|
| 65 |
|
|---|
| 66 | date >> $scriptlog 2>&1
|
|---|
| 67 |
|
|---|
| 68 | if [ ! -d $getstatuslogpath ]
|
|---|
| 69 | then
|
|---|
| 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
|
|---|
| 77 | fi
|
|---|
| 78 |
|
|---|
| 79 | date > $lockpath/lock-buildsequenceentries.txt >> $scriptlog 2>&1
|
|---|
| 80 | checklock0=$?
|
|---|
| 81 | case $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;;
|
|---|
| 88 | esac
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 | echo "getting list..." >> $scriptlog 2>&1
|
|---|
| 92 | check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\) | tee $getstatus.log | grep int | sed -e 's/(int)//'`
|
|---|
| 93 |
|
|---|
| 94 | case $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;;
|
|---|
| 97 | esac
|
|---|
| 98 |
|
|---|
| 99 | dates=(`cat $todofile`)
|
|---|
| 100 |
|
|---|
| 101 | if [ "$dates" = "" ]
|
|---|
| 102 | then
|
|---|
| 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
|
|---|
| 108 | fi
|
|---|
| 109 |
|
|---|
| 110 | echo "dates: "${dates[@]} >> $scriptlog 2>&1
|
|---|
| 111 |
|
|---|
| 112 | for date in ${dates[@]}
|
|---|
| 113 | do
|
|---|
| 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
|
|---|
| 148 | done
|
|---|
| 149 |
|
|---|
| 150 | rm -v $todofile >> $scriptlog 2>&1
|
|---|
| 151 | rm -v $lockpath/lock-buildsequenceentries.txt >> $scriptlog 2>&1
|
|---|
| 152 |
|
|---|
| 153 | set +C
|
|---|
| 154 |
|
|---|
| 155 | date >> $scriptlog 2>&1
|
|---|
| 156 |
|
|---|