| 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 | #failed codes
|
|---|
| 53 | #sequence build status
|
|---|
| 54 | Fbuildsequ=1
|
|---|
| 55 | Fdoexcl=2
|
|---|
| 56 | #run process status
|
|---|
| 57 | Ftimecorr=3
|
|---|
| 58 | Ffillraw=4
|
|---|
| 59 | Fsinope=5
|
|---|
| 60 | Ffillsinope=6
|
|---|
| 61 | Fresetexcl=7
|
|---|
| 62 | #sequence process status
|
|---|
| 63 | Fwritesequfile=8
|
|---|
| 64 | Ffilesavail=9
|
|---|
| 65 | Fnoccfile=10
|
|---|
| 66 | Fnocacofile=11
|
|---|
| 67 | Fmerppcc=12
|
|---|
| 68 | Fmerppcaco=13
|
|---|
| 69 | Fcallisto=14
|
|---|
| 70 | Ffillcalib=15
|
|---|
| 71 | Ffillsignal=16
|
|---|
| 72 | Fstar=17
|
|---|
| 73 | Ffillstar=18
|
|---|
| 74 | #dataset process status
|
|---|
| 75 | Fstardone=19
|
|---|
| 76 | Fganymed=20
|
|---|
| 77 | Ffillganymed=21
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 | function finish()
|
|---|
| 82 | {
|
|---|
| 83 | rm -v $todofile
|
|---|
| 84 | rm -v $lockfile
|
|---|
| 85 | date
|
|---|
| 86 | exit
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | function makedir()
|
|---|
| 90 | {
|
|---|
| 91 | if [ ! -d $@ ]
|
|---|
| 92 | then
|
|---|
| 93 | mkdir -pv $@
|
|---|
| 94 | if [ ! -d $@ ]
|
|---|
| 95 | then
|
|---|
| 96 | echo "could not make dir "$@
|
|---|
| 97 | finish
|
|---|
| 98 | fi
|
|---|
| 99 | fi
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | function checklock()
|
|---|
| 103 | {
|
|---|
| 104 | date > $lockfile
|
|---|
| 105 | checklock0=$?
|
|---|
| 106 | case $checklock0 in
|
|---|
| 107 | 0) echo "checklock0=$checklock0 -> continue " ;;
|
|---|
| 108 | 1) echo "checklock0=$checklock0 -> file $lockfile exists "
|
|---|
| 109 | echo "-> $@ $program is running -> exit"
|
|---|
| 110 | date
|
|---|
| 111 | exit;;
|
|---|
| 112 | *) echo "checklock0=$checklock0 -> something went completely wrong" ;;
|
|---|
| 113 | esac
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | function getdolist()
|
|---|
| 117 | {
|
|---|
| 118 | datetime=`date +%F-%H-%M-%S`
|
|---|
| 119 | year=`date +%Y`
|
|---|
| 120 | date=NULL
|
|---|
| 121 |
|
|---|
| 122 | getstatuslogpath=$logpath/getstatus/$program/$year
|
|---|
| 123 | getstatuslog=$getstatuslogpath/getstatus-$table-$column-$datetime.log
|
|---|
| 124 | makedir $getstatuslogpath
|
|---|
| 125 |
|
|---|
| 126 | # get todo list
|
|---|
| 127 | echo "getting todo list..."
|
|---|
| 128 | check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatus | grep int | sed -e 's/(int)//'`
|
|---|
| 129 |
|
|---|
| 130 | case $check0 in
|
|---|
| 131 | 1) echo "check0=$check0 -> everything ok, got todo list -> run $program";;
|
|---|
| 132 | *) echo "check0=$check0 -> ERROR -> could not get todo list -> exit"
|
|---|
| 133 | finish ;;
|
|---|
| 134 | esac
|
|---|
| 135 |
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | function resetstatusvalues()
|
|---|
| 139 | {
|
|---|
| 140 | statustime=NULL
|
|---|
| 141 | starttime=NULL
|
|---|
| 142 | returncode=NULL
|
|---|
| 143 | failedcode=NULL
|
|---|
| 144 | failedcodeadd=NULL
|
|---|
| 145 | failedtime=NULL
|
|---|
| 146 | }
|
|---|
| 147 |
|
|---|
| 148 | function printstatusvalues()
|
|---|
| 149 | {
|
|---|
| 150 | echo "the current values are:"
|
|---|
| 151 | echo " statustime=$statustime"
|
|---|
| 152 | echo " starttime=$starttime"
|
|---|
| 153 | echo " returncode=$returncode"
|
|---|
| 154 | echo " failedcode=$failedcode"
|
|---|
| 155 | echo " failedcodeadd=$failedcodeadd"
|
|---|
| 156 | echo " failedtime=$failedtime"
|
|---|
| 157 | echo "-- check: -$check-"
|
|---|
| 158 | echo ""
|
|---|
| 159 | }
|
|---|
| 160 |
|
|---|
| 161 | function setstatus()
|
|---|
| 162 | {
|
|---|
| 163 | # set status values
|
|---|
| 164 | resetstatusvalues
|
|---|
| 165 | case $@ in
|
|---|
| 166 | start) echo "start"
|
|---|
| 167 | starttime="Now()"
|
|---|
| 168 | ;;
|
|---|
| 169 | stop) echo "stop"
|
|---|
| 170 | case $check in
|
|---|
| 171 | ok) echo " ok"
|
|---|
| 172 | statustime="Now()"
|
|---|
| 173 | ;;
|
|---|
| 174 | *) echo " failed"
|
|---|
| 175 | starttime=noreset
|
|---|
| 176 | returncode=$check
|
|---|
| 177 | failedcode=$com
|
|---|
| 178 | if ! [ "$comadd" = "" ]
|
|---|
| 179 | then
|
|---|
| 180 | failedcodeadd=$comadd
|
|---|
| 181 | fi
|
|---|
| 182 | failedtime="Now()"
|
|---|
| 183 | ;;
|
|---|
| 184 | esac
|
|---|
| 185 | ;;
|
|---|
| 186 | *) echo "error -> exit"
|
|---|
| 187 | exit
|
|---|
| 188 | ;;
|
|---|
| 189 | esac
|
|---|
| 190 |
|
|---|
| 191 | # printstatusvalues
|
|---|
| 192 | # set status
|
|---|
| 193 | setstatuslogpath=$logpath/setstatus/$program/$var1
|
|---|
| 194 | makedir $setstatuslogpath
|
|---|
| 195 | setstatuslog=$setstatuslogpath/setstatus-$@-$program-$var2.log
|
|---|
| 196 | checkstatus=`root -q -b $macrospath/setstatus.C+\("\"$sequence\""\,"\"$table\""\,"\"$column\""\,"\"$statustime\""\,"\"$returncode\""\,"\"$failedcode\""\,"\"$failedcodeadd\""\,"\"$starttime\""\,"\"$failedtime\""\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
|
|---|
| 197 | case $checkstatus in
|
|---|
| 198 | 1) echo "checkstatus=$checkstatus -> everything ok, status has been set";;
|
|---|
| 199 | *) echo "checkstatus=$checkstatus -> ERROR -> step could not be set -> exit"
|
|---|
| 200 | finish ;;
|
|---|
| 201 | esac
|
|---|
| 202 | }
|
|---|
| 203 |
|
|---|
| 204 |
|
|---|
| 205 |
|
|---|