1 | #!/bin/bash
|
---|
2 | #
|
---|
3 |
|
---|
4 | source `dirname $0`/../Sourcefile.sh
|
---|
5 | printprocesslog "INFO starting $0"
|
---|
6 | program=CheckRawFilesAvail
|
---|
7 | step=RawFileAvailISDC
|
---|
8 | transferdelay=3 #days
|
---|
9 | failsdir=/archive/fact/fails/raw
|
---|
10 |
|
---|
11 | set -C
|
---|
12 |
|
---|
13 | # check if script is already running
|
---|
14 | lockfile=$lockpath/lock-$program.txt
|
---|
15 | checklock
|
---|
16 |
|
---|
17 | # get todo list
|
---|
18 | gettodo
|
---|
19 |
|
---|
20 |
|
---|
21 | for (( s=0 ; s < $num ; s++ ))
|
---|
22 | do
|
---|
23 | night=${primaries[$s+$s]}
|
---|
24 | runid=${primaries[$s+$s+1]}
|
---|
25 | currentnight=`date +%Y%m%d`
|
---|
26 | checknight=`echo " $currentnight - $transferdelay " | bc -l`
|
---|
27 |
|
---|
28 | setstatus "start"
|
---|
29 |
|
---|
30 | night2=`echo $night | cut -c 1-4`/`echo $night | cut -c 5-6`/`echo $night | cut -c 7-8`
|
---|
31 | rawfile=$rawdata/$night2/$night"_"`printf %03d $runid`".fits.gz"
|
---|
32 | failsfile=$failsdir/$night2/$night"_"`printf %03d $runid`".fits.gz"
|
---|
33 |
|
---|
34 | test -e $rawfile
|
---|
35 | check1=$?
|
---|
36 |
|
---|
37 | query="SELECT fHasDrsFile from RunInfo WHERE fNight="$night" AND fRunID="$runid
|
---|
38 | numdrs=`sendquery`
|
---|
39 | if [ $numdrs -gt 0 ]
|
---|
40 | then
|
---|
41 | drsfile=$rawdata/$night2"/"$night"_"`printf %03d $runid`".drs.fits.gz"
|
---|
42 | failsdrsfile=$failsdir/$night2"/"$night"_"`printf %03d $runid`".drs.fits.gz"
|
---|
43 | test -e $drsfile
|
---|
44 | check3=$?
|
---|
45 | fi
|
---|
46 |
|
---|
47 | case $check1 in
|
---|
48 | 0) printprocesslog "INFO found rawfile "$rawfile
|
---|
49 | if [ $numdrs -gt 0 ]
|
---|
50 | then
|
---|
51 | case $check3 in
|
---|
52 | 0) printprocesslog "INFO found drsfile "$drsfile
|
---|
53 | ;;
|
---|
54 | *) test -e $failsdrsfile
|
---|
55 | check4=$?
|
---|
56 | case $check4 in
|
---|
57 | 0) printprocesslog "INFO found rawfile in "$failsdrsfile
|
---|
58 | # drs file is not in archive for files which are ok
|
---|
59 | check=$check4
|
---|
60 | ;;
|
---|
61 | *) # print warning only for files which are older than $transferdelay days
|
---|
62 | if [ $night -lt $checknight ]
|
---|
63 | then
|
---|
64 | printprocesslog "WARN "$drsfile" and "$failsdrsfile" missing."
|
---|
65 | else
|
---|
66 | printprocesslog "INFO "$drsfile" and "$failsdrsfile" missing."
|
---|
67 | fi
|
---|
68 | check="no"
|
---|
69 | ;;
|
---|
70 | esac
|
---|
71 | esac
|
---|
72 | fi
|
---|
73 | ;;
|
---|
74 | *) test -e $failsfile
|
---|
75 | check2=$?
|
---|
76 |
|
---|
77 | case $check2 in
|
---|
78 | 0) printprocesslog "INFO found rawfile in "$failsfile
|
---|
79 | # raw file is not in archive for files which are ok
|
---|
80 | check=$check2
|
---|
81 | ;;
|
---|
82 | *) # print warning only for files which are older than $transferdelay days
|
---|
83 | if [ $night -lt $checknight ]
|
---|
84 | then
|
---|
85 | printprocesslog "WARN "$rawfile" and "$failsfile" missing."
|
---|
86 | else
|
---|
87 | printprocesslog "INFO "$rawfile" and "$failsfile" missing."
|
---|
88 | fi
|
---|
89 | check="no"
|
---|
90 | ;;
|
---|
91 | esac
|
---|
92 | ;;
|
---|
93 | esac
|
---|
94 |
|
---|
95 | setstatus "stop"
|
---|
96 | done
|
---|
97 |
|
---|
98 | finish
|
---|
99 |
|
---|