| 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 | table=DataSetProcessStatus
|
|---|
| 33 | column=fStarFilesAvail
|
|---|
| 34 | date=NULL
|
|---|
| 35 | datetime=`date +%F-%H-%M-%S`
|
|---|
| 36 | year=`date +%Y`
|
|---|
| 37 |
|
|---|
| 38 | todofile=$listpath/ToDo-$table-$column.txt
|
|---|
| 39 | getstatuslogpath=$logpath/getstatus/checkstardone/$year
|
|---|
| 40 | getstatuslog=$getstatuslogpath/getstatus-$table-$column-$datetime.log
|
|---|
| 41 |
|
|---|
| 42 | scriptlogpath=$logpath/run/checkstardone/`date +%Y/%m/%d`
|
|---|
| 43 | makedir $scriptlogpath
|
|---|
| 44 |
|
|---|
| 45 | scriptlog=$scriptlogpath/checkstardone-$datetime.log
|
|---|
| 46 |
|
|---|
| 47 | date >> $scriptlog 2>&1
|
|---|
| 48 |
|
|---|
| 49 | makedir $getstatuslogpath >> $scriptlog 2>&1
|
|---|
| 50 |
|
|---|
| 51 | cd $mars
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 | if [ -e $todofile ]
|
|---|
| 55 | then
|
|---|
| 56 | echo "checkstardone is already running -> exit" >> $scriptlog 2>&1
|
|---|
| 57 | exit
|
|---|
| 58 | fi
|
|---|
| 59 |
|
|---|
| 60 | echo "getting list..." >> $scriptlog 2>&1
|
|---|
| 61 | check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
|
|---|
| 62 |
|
|---|
| 63 | case $check0 in
|
|---|
| 64 | 1) echo "check0=$check0 -> everything ok -> do step" >> $scriptlog 2>&1 ;;
|
|---|
| 65 | *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1 ;;
|
|---|
| 66 | esac
|
|---|
| 67 |
|
|---|
| 68 | datasets=(`cat $todofile`)
|
|---|
| 69 |
|
|---|
| 70 | if [ "$datasets" = "" ]
|
|---|
| 71 | then
|
|---|
| 72 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
|---|
| 73 | rm -v $todofile >> $scriptlog 2>&1
|
|---|
| 74 | rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
|
|---|
| 75 | date >> $scriptlog 2>&1
|
|---|
| 76 | exit
|
|---|
| 77 | fi
|
|---|
| 78 |
|
|---|
| 79 | echo "datasets: "${datasets[@]} #>> $scriptlog 2>&1
|
|---|
| 80 |
|
|---|
| 81 | for dataset in ${datasets[@]}
|
|---|
| 82 | do
|
|---|
| 83 | no=`printf %08d $dataset | cut -c 0-5`
|
|---|
| 84 | echo "checking files for dataset $dataset..." >> $scriptlog 2>&1
|
|---|
| 85 | datasetfile=$datasetpath/$no/dataset`printf %08d $dataset`.txt
|
|---|
| 86 | sequences=(`cat $datasetfile | grep Sequences | sed -e 's/SequencesOn://g' | sed -e 's/SequencesOff://g'`)
|
|---|
| 87 |
|
|---|
| 88 | if [ "$sequences" = "" ]
|
|---|
| 89 | then
|
|---|
| 90 | echo "no sequences found" >> $scriptlog 2>&1
|
|---|
| 91 | echo "continue with next dataset" >> $scriptlog 2>&1
|
|---|
| 92 | continue
|
|---|
| 93 | fi
|
|---|
| 94 |
|
|---|
| 95 | echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
|
|---|
| 96 |
|
|---|
| 97 | outpath=$logpath/checkstardone/$no
|
|---|
| 98 | echo "outpath: "$outpath >> $scriptlog 2>&1
|
|---|
| 99 | makedir $outpath >> $scriptlog 2>&1
|
|---|
| 100 |
|
|---|
| 101 | for sequence in ${sequences[@]}
|
|---|
| 102 | do
|
|---|
| 103 | check1=`root -q -b $macrospath/checkstardone.C+\(\""$sequence\""\) | tee $outpath/checkstardone-$sequence.log | grep int | sed -e 's/(int)//'`
|
|---|
| 104 |
|
|---|
| 105 | case $check1 in
|
|---|
| 106 | 1) echo "check1=$check1 -> everything ok -> continue with next sequence..." >> $scriptlog 2>&1 ;;
|
|---|
| 107 | *) echo "check1=$check1 -> ERROR " >> $scriptlog 2>&1
|
|---|
| 108 | echo "starfiles not available for sequence -> continue" >> $scriptlog 2>&1
|
|---|
| 109 | continue 2
|
|---|
| 110 | ;;
|
|---|
| 111 | esac
|
|---|
| 112 | done
|
|---|
| 113 |
|
|---|
| 114 | setstatuslogpath=$logpath/setstatus/checkstardone/$no
|
|---|
| 115 | makedir $setstatuslogpath >> $scriptlog 2>&1
|
|---|
| 116 |
|
|---|
| 117 | check2=`root -q -b $macrospath/setstatus.C+\("\"$dataset\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslogpath/setstatus-checkstardone-$dataset.log | grep int | sed -e 's/(int)//'`
|
|---|
| 118 | case $check2 in
|
|---|
| 119 | 1) echo "check2=$check2 -> everything ok, status has been set" >> $scriptlog 2>&1 ;;
|
|---|
| 120 | *) echo "check2=$check2 -> ERROR -> step could not be set" >> $scriptlog 2>&1 ;;
|
|---|
| 121 | esac
|
|---|
| 122 | done
|
|---|
| 123 |
|
|---|
| 124 | rm -v $todofile >> $scriptlog 2>&1
|
|---|
| 125 | rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
|
|---|
| 126 |
|
|---|
| 127 | date >> $scriptlog 2>&1
|
|---|
| 128 |
|
|---|