| 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 05/2005 <mailto:dorner@astro.uni-wuerzburg.de>
|
|---|
| 21 | #
|
|---|
| 22 | # Copyright: MAGIC Software Development, 2000-2006
|
|---|
| 23 | #
|
|---|
| 24 | #
|
|---|
| 25 | # ========================================================================
|
|---|
| 26 | #
|
|---|
| 27 | # This a resource file for the scripts, in which the standard paths and
|
|---|
| 28 | # functions, which are needed more often are stored.
|
|---|
| 29 | #
|
|---|
| 30 |
|
|---|
| 31 | export ROOTSYS=/opt/root_v4.04.02g
|
|---|
| 32 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROOTSYS/lib
|
|---|
| 33 | export PATH=$PATH:$ROOTSYS/bin
|
|---|
| 34 |
|
|---|
| 35 | mars=/home/operator/Mars
|
|---|
| 36 | macrospath=$mars/datacenter/macros
|
|---|
| 37 | scriptspath=$mars/datacenter/scripts
|
|---|
| 38 |
|
|---|
| 39 | logpath=/magic/datacenter/autologs
|
|---|
| 40 | lockpath=/magic/datacenter/locks
|
|---|
| 41 | listpath=/magic/datacenter/lists
|
|---|
| 42 | setuppath=/magic/datacenter/setup
|
|---|
| 43 |
|
|---|
| 44 | datapath=/magic/data
|
|---|
| 45 | subsystempath=/magic/subsystemdata
|
|---|
| 46 | sequpath=/magic/sequences
|
|---|
| 47 | datasetpath=/magic/datasets
|
|---|
| 48 |
|
|---|
| 49 | check="ok"
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 | function makedir()
|
|---|
| 53 | {
|
|---|
| 54 | if [ ! -d $@ ]
|
|---|
| 55 | then
|
|---|
| 56 | mkdir -pv $@
|
|---|
| 57 | if [ ! -d $@ ]
|
|---|
| 58 | then
|
|---|
| 59 | echo "could not make dir "$@
|
|---|
| 60 | exit
|
|---|
| 61 | fi
|
|---|
| 62 | fi
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | function finish()
|
|---|
| 66 | {
|
|---|
| 67 | rm -v $todofile
|
|---|
| 68 | rm -v $lockfile
|
|---|
| 69 | date
|
|---|
| 70 | exit
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | function getdolist()
|
|---|
| 74 | {
|
|---|
| 75 | datetime=`date +%F-%H-%M-%S`
|
|---|
| 76 | year=`date +%Y`
|
|---|
| 77 | date=NULL
|
|---|
| 78 |
|
|---|
| 79 | getstatuslogpath=$logpath/getstatus/$program/$year
|
|---|
| 80 | getstatuslog=$getstatuslogpath/getstatus-$table-$column-$datetime.log
|
|---|
| 81 | makedir $getstatuslogpath
|
|---|
| 82 |
|
|---|
| 83 | # get todo list
|
|---|
| 84 | echo "getting todo list..."
|
|---|
| 85 | check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatus | grep int | sed -e 's/(int)//'`
|
|---|
| 86 |
|
|---|
| 87 | case $check0 in
|
|---|
| 88 | 1) echo "check0=$check0 -> everything ok, got todo list -> run $program";;
|
|---|
| 89 | *) echo "check0=$check0 -> ERROR -> could not get todo list -> exit"
|
|---|
| 90 | finish ;;
|
|---|
| 91 | esac
|
|---|
| 92 |
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | function resetstatusvalues()
|
|---|
| 96 | {
|
|---|
| 97 | statustime=NULL
|
|---|
| 98 | starttime=NULL
|
|---|
| 99 | failedcode=NULL
|
|---|
| 100 | failedcomment=NULL
|
|---|
| 101 | failedtime=NULL
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | function printstatusvalues()
|
|---|
| 105 | {
|
|---|
| 106 | echo "the current values are:"
|
|---|
| 107 | echo " statustime=$statustime"
|
|---|
| 108 | echo " starttime=$starttime"
|
|---|
| 109 | echo " failedcode=$failedcode"
|
|---|
| 110 | echo " failedcomment=$failedcomment"
|
|---|
| 111 | echo " failedtime=$failedtime"
|
|---|
| 112 | echo "-- check: -$check-"
|
|---|
| 113 | echo ""
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | function setstatus()
|
|---|
| 117 | {
|
|---|
| 118 | # set status values
|
|---|
| 119 | resetstatusvalues
|
|---|
| 120 | case $@ in
|
|---|
| 121 | start) echo "start"
|
|---|
| 122 | starttime="Now()"
|
|---|
| 123 | ;;
|
|---|
| 124 | stop) echo "stop"
|
|---|
| 125 | case $check in
|
|---|
| 126 | ok) echo " ok"
|
|---|
| 127 | statustime="Now()"
|
|---|
| 128 | ;;
|
|---|
| 129 | *) echo " failed"
|
|---|
| 130 | starttime=noreset
|
|---|
| 131 | failedcode=$check
|
|---|
| 132 | failedcomment=$com
|
|---|
| 133 | failedtime="Now()"
|
|---|
| 134 | ;;
|
|---|
| 135 | esac
|
|---|
| 136 | ;;
|
|---|
| 137 | *) echo "error -> exit"
|
|---|
| 138 | exit
|
|---|
| 139 | ;;
|
|---|
| 140 | esac
|
|---|
| 141 |
|
|---|
| 142 | # printstatusvalues
|
|---|
| 143 | # set status
|
|---|
| 144 | setstatuslogpath=$logpath/setstatus/$program/$var1
|
|---|
| 145 | makedir $setstatuslogpath
|
|---|
| 146 | setstatuslog=$setstatuslogpath/setstatus-$@-$program-$var2.log
|
|---|
| 147 | checkstatus=`root -q -b $macrospath/setstatus.C+\("\"$sequence\""\,"\"$table\""\,"\"$column\""\,"\"$statustime\""\,"\"$failedcode\""\,"\"$failedcomment\""\,"\"$starttime\""\,"\"$failedtime\""\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
|
|---|
| 148 | case $checkstatus in
|
|---|
| 149 | 1) echo "checkstatus=$checkstatus -> everything ok, status has been set";;
|
|---|
| 150 | *) echo "checkstatus=$checkstatus -> ERROR -> step could not be set -> exit"
|
|---|
| 151 | finish ;;
|
|---|
| 152 | esac
|
|---|
| 153 | }
|
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 |
|
|---|