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