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