| 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 | table=SequenceProcessStatus
|
|---|
| 35 | column=fSequenceFileWritten
|
|---|
| 36 | date=NULL
|
|---|
| 37 | datetime=`date +%F-%H-%M-%S`
|
|---|
| 38 | year=`date +%Y`
|
|---|
| 39 |
|
|---|
| 40 | todofile=$listpath/ToDo-$table-$column.txt
|
|---|
| 41 | getstatuslogpath=$logpath/getstatus/writesequencefiles/$year
|
|---|
| 42 | getstatuslog=$getstatuslogpath/getstatus-writesequencefiles-$datetime.log
|
|---|
| 43 |
|
|---|
| 44 | scriptlogpath=$logpath/run/writesequencefiles/`date +%Y/%m/%d`
|
|---|
| 45 | if [ ! -d $scriptlogpath ]
|
|---|
| 46 | then
|
|---|
| 47 | mkdir -pv $scriptlogpath
|
|---|
| 48 | if [ ! -d $scriptlogpath ]
|
|---|
| 49 | then
|
|---|
| 50 | echo "could not make scriptlogpath "$scriptlogpath
|
|---|
| 51 | exit
|
|---|
| 52 | fi
|
|---|
| 53 | fi
|
|---|
| 54 |
|
|---|
| 55 | scriptlog=$scriptlogpath/runwritesequencefiles-$datetime.log
|
|---|
| 56 |
|
|---|
| 57 | date >> $scriptlog 2>&1
|
|---|
| 58 |
|
|---|
| 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 | cd $mars
|
|---|
| 72 |
|
|---|
| 73 | date > $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
|
|---|
| 74 | checklock0=$?
|
|---|
| 75 | case $checklock0 in
|
|---|
| 76 | 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
|
|---|
| 77 | 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
|
|---|
| 78 | echo "-> writesequencefiles is running -> exit" >> $scriptlog 2>&1
|
|---|
| 79 | date >> $scriptlog 2>&1
|
|---|
| 80 | exit;;
|
|---|
| 81 | *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
|
|---|
| 82 | esac
|
|---|
| 83 |
|
|---|
| 84 | echo "getting list..." >> $scriptlog 2>&1
|
|---|
| 85 | check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
|
|---|
| 86 |
|
|---|
| 87 | case $check0 in
|
|---|
| 88 | 1) echo "check0=$check0 -> everthing ok -> run writesequencefiles" >> $scriptlog 2>&1;;
|
|---|
| 89 | *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
|---|
| 90 | esac
|
|---|
| 91 |
|
|---|
| 92 | sequences=(`cat $todofile`)
|
|---|
| 93 |
|
|---|
| 94 | if [ "$sequences" = "" ]
|
|---|
| 95 | then
|
|---|
| 96 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
|---|
| 97 | rm -v $todofile >> $scriptlog 2>&1
|
|---|
| 98 | rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
|
|---|
| 99 | date >> $scriptlog 2>&1
|
|---|
| 100 | exit
|
|---|
| 101 | fi
|
|---|
| 102 |
|
|---|
| 103 | echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
|
|---|
| 104 |
|
|---|
| 105 | for sequence in ${sequences[@]}
|
|---|
| 106 | do
|
|---|
| 107 | no=`printf %08d $sequence | cut -c 0-4`
|
|---|
| 108 | no2=`printf %08d $sequence`
|
|---|
| 109 | sequencepath=/magic/sequences/$no
|
|---|
| 110 | if [ ! -d $sequencepath ]
|
|---|
| 111 | then
|
|---|
| 112 | mkdir -pv $sequencepath >> $scriptlog 2>&1
|
|---|
| 113 | if [ ! -d $sequencepath ]
|
|---|
| 114 | then
|
|---|
| 115 | echo "could not make sequencepath $sequencepath -> continue " >> $scriptlog 2>&1
|
|---|
| 116 | continue
|
|---|
| 117 | fi
|
|---|
| 118 | fi
|
|---|
| 119 |
|
|---|
| 120 | writesequencefilelogpath=$logpath/writesequencefile/$no
|
|---|
| 121 | echo "writesequencefilelogpath: "$writesequencefilelogpath >> $scriptlog 2>&1
|
|---|
| 122 | if [ ! -d $writesequencefilelogpath ]
|
|---|
| 123 | then
|
|---|
| 124 | mkdir -pv $writesequencefilelogpath >> $scriptlog 2>&1
|
|---|
| 125 | if [ ! -d $writesequencefilelogpath ]
|
|---|
| 126 | then
|
|---|
| 127 | echo "could not make writesequencefilelogpath $writesequencefilelogpath -> continue " >> $scriptlog 2>&1
|
|---|
| 128 | continue
|
|---|
| 129 | fi
|
|---|
| 130 | fi
|
|---|
| 131 |
|
|---|
| 132 | echo "write sequencefile for sequence $sequence" >> $scriptlog 2>&1
|
|---|
| 133 | check2=`root -q -b $macrospath/writesequencefile.C+\($sequence\) | tee $writesequencefilelogpath/writesequencefile-$no2.log | grep int | sed -e 's/(int)//'`
|
|---|
| 134 | case $check2 in
|
|---|
| 135 | 1) echo "check2=$check2 -> everthing ok " >> $scriptlog 2>&1
|
|---|
| 136 | echo "-> inserting the status for writesequencefile for sequence $sequence into the db" >> $scriptlog 2>&1
|
|---|
| 137 | setstatuslogpath=$logpath/setstatus/writesequencefile/$no
|
|---|
| 138 | if [ ! -d $setstatuslogpath ]
|
|---|
| 139 | then
|
|---|
| 140 | mkdir -pv $setstatuslogpath >> $scriptlog 2>&1
|
|---|
| 141 | if [ ! -d $setstatuslogpath ]
|
|---|
| 142 | then
|
|---|
| 143 | echo "could not make setstatuslogpath "$setstatuslogpath >> $scriptlog 2>&1
|
|---|
| 144 | continue
|
|---|
| 145 | fi
|
|---|
| 146 | fi
|
|---|
| 147 | setstatuslog=$setstatuslogpath/setstatus-writesequencefile-$no2.log
|
|---|
| 148 | check4=`root -q -b $macrospath/setstatus.C+\("\"$sequence\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
|
|---|
| 149 | case $check4 in
|
|---|
| 150 | 1) echo "check4=$check4 -> everthing ok, status has been set" >> $scriptlog 2>&1;;
|
|---|
| 151 | *) echo "check4=$check4 -> ERROR -> step could not be set" >> $scriptlog 2>&1;;
|
|---|
| 152 | esac
|
|---|
| 153 | ;;
|
|---|
| 154 | *) echo "check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
|---|
| 155 | esac
|
|---|
| 156 | done
|
|---|
| 157 |
|
|---|
| 158 | rm -v $todofile >> $scriptlog 2>&1
|
|---|
| 159 | rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
|
|---|
| 160 |
|
|---|
| 161 | set +C
|
|---|
| 162 |
|
|---|
| 163 | date >> $scriptlog 2>&1
|
|---|
| 164 |
|
|---|