| 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 | source /home/operator/Mars/datacenter/scripts/sourcefile
|
|---|
| 30 |
|
|---|
| 31 | set -C
|
|---|
| 32 |
|
|---|
| 33 | cd $mars
|
|---|
| 34 |
|
|---|
| 35 | table=SequenceBuildStatus
|
|---|
| 36 | column=fSequenceEntriesBuilt
|
|---|
| 37 | date=NULL
|
|---|
| 38 | datetime=`date +%F-%H-%M-%S`
|
|---|
| 39 | year=`date +%Y`
|
|---|
| 40 |
|
|---|
| 41 | todofile=/magic/datacenter/lists/ToDo-$table-$column.txt
|
|---|
| 42 | getstatuslogpath=$logpath/getstatus/buildsequenceentries/$year
|
|---|
| 43 | getstatuslog=$getstatuslogpath/getstatus-buildsequenceentries-$datetime.log
|
|---|
| 44 |
|
|---|
| 45 | scriptlogpath=$logpath/run/buildsequenceentries/`date +%Y/%m`
|
|---|
| 46 | if [ ! -d $scriptlogpath ]
|
|---|
| 47 | then
|
|---|
| 48 | mkdir -pv $scriptlogpath
|
|---|
| 49 | if [ ! -d $scriptlogpath ]
|
|---|
| 50 | then
|
|---|
| 51 | echo "could not make scriptlogpath "$scriptlogpath
|
|---|
| 52 | exit
|
|---|
| 53 | fi
|
|---|
| 54 | fi
|
|---|
| 55 |
|
|---|
| 56 | scriptlog=$scriptlogpath/buildsequenceentries-$datetime.log
|
|---|
| 57 |
|
|---|
| 58 | date >> $scriptlog 2>&1
|
|---|
| 59 |
|
|---|
| 60 | if [ ! -d $getstatuslogpath ]
|
|---|
| 61 | then
|
|---|
| 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
|
|---|
| 69 | fi
|
|---|
| 70 |
|
|---|
| 71 | date > $lockpath/lock-buildsequenceentries.txt >> $scriptlog 2>&1
|
|---|
| 72 | checklock0=$?
|
|---|
| 73 | case $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;;
|
|---|
| 80 | esac
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 | echo "getting list..." >> $scriptlog 2>&1
|
|---|
| 84 | check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\) | tee $getstatus.log | grep int | sed -e 's/(int)//'`
|
|---|
| 85 |
|
|---|
| 86 | case $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;;
|
|---|
| 89 | esac
|
|---|
| 90 |
|
|---|
| 91 | dates=(`cat $todofile`)
|
|---|
| 92 |
|
|---|
| 93 | if [ "$dates" = "" ]
|
|---|
| 94 | then
|
|---|
| 95 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
|---|
| 96 | rm -v $todofile >> $scriptlog 2>&1
|
|---|
| 97 | rm -v $lockpath/lock-buildsequenceentries.txt >> $scriptlog 2>&1
|
|---|
| 98 | date >> $scriptlog 2>&1
|
|---|
| 99 | exit
|
|---|
| 100 | fi
|
|---|
| 101 |
|
|---|
| 102 | echo "dates: "${dates[@]} >> $scriptlog 2>&1
|
|---|
| 103 |
|
|---|
| 104 | for date in ${dates[@]}
|
|---|
| 105 | do
|
|---|
| 106 | echo "building sequence entries for date $date..." >> $scriptlog 2>&1
|
|---|
| 107 | year2=`echo $date | cut -c 1-4`
|
|---|
| 108 | buildsequentriespath=$logpath/buildsequenceentries/$year2
|
|---|
| 109 | if [ ! -d $buildsequentriespath ]
|
|---|
| 110 | then
|
|---|
| 111 | mkdir -pv $buildsequentriespath >> $scriptlog 2>&1
|
|---|
| 112 | if [ ! -d $buildsequentriespath ]
|
|---|
| 113 | then
|
|---|
| 114 | echo "could not make buildsequentriespath "$buildsequentriespath >> $scriptlog 2>&1
|
|---|
| 115 | continue
|
|---|
| 116 | fi
|
|---|
| 117 | fi
|
|---|
| 118 | check1=`root -q -b $macrospath/buildsequenceentries.C+\("\"$date\""\,kFALSE\) | tee $buildsequentriespath/buildsequenceentries-$date.log | grep int | sed -e 's/(int)//'`
|
|---|
| 119 |
|
|---|
| 120 | case $check1 in
|
|---|
| 121 | 1) echo "check1=$check1 -> everthing ok -> setting status..." >> $scriptlog 2>&1
|
|---|
| 122 | setstatuslogpath=$logpath/setstatus/buildsequenceentries/$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-buildsequenceentries-$date.log | grep int | sed -e 's/(int)//'`
|
|---|
| 133 | case $check2 in
|
|---|
| 134 | 1) echo "check2=$check2 -> everthing ok, status has been set" >> $scriptlog 2>&1;;
|
|---|
| 135 | *) echo "check2=$check2 -> ERROR -> step could not be set" >> $scriptlog 2>&1;;
|
|---|
| 136 | esac
|
|---|
| 137 | ;;
|
|---|
| 138 | *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
|---|
| 139 | esac
|
|---|
| 140 | done
|
|---|
| 141 |
|
|---|
| 142 | rm -v $todofile >> $scriptlog 2>&1
|
|---|
| 143 | rm -v $lockpath/lock-buildsequenceentries.txt >> $scriptlog 2>&1
|
|---|
| 144 |
|
|---|
| 145 | set +C
|
|---|
| 146 |
|
|---|
| 147 | date >> $scriptlog 2>&1
|
|---|
| 148 |
|
|---|