1 | #!/bin/sh |
---|
2 | #download SCA file, proceed to introspection, and upload results |
---|
3 | DATE=/bin/date |
---|
4 | GREP=/bin/grep |
---|
5 | AWK=/bin/awk |
---|
6 | ECHO=/bin/echo |
---|
7 | WC=/usr/bin/wc |
---|
8 | CAT=/bin/cat |
---|
9 | PRINTF=/usr/bin/printf |
---|
10 | MKDIR=/bin/mkdir |
---|
11 | RM=/bin/rm |
---|
12 | LS=/bin/ls |
---|
13 | DefaultIFS=$' \t\n' |
---|
14 | IFS=$DefaultIFS |
---|
15 | |
---|
16 | |
---|
17 | #set Irods environment |
---|
18 | . /usr/local/shared/bin/irods_env.sh -noverbose |
---|
19 | |
---|
20 | scriptName="`basename $0`" |
---|
21 | $ECHO "Processing script ${scriptName} at `date`" |
---|
22 | |
---|
23 | #which source to analyse |
---|
24 | sourceRadio=$1 |
---|
25 | |
---|
26 | #Path to public backupable path |
---|
27 | publicpath="/afs/in2p3.fr/home/c/campagne/public" |
---|
28 | |
---|
29 | #temporary files to synchronize scripts |
---|
30 | tmppublicpath=${TMPPUBLICPATH} |
---|
31 | $LS -l ${tmppublicpath} > /dev/null |
---|
32 | |
---|
33 | |
---|
34 | #Path where the job will do temporary IO |
---|
35 | . ${SCRIPTPATH}/set_iojobpath.sh |
---|
36 | iojobpath=$(set_iojobpath) |
---|
37 | cd ${iojobpath} |
---|
38 | |
---|
39 | |
---|
40 | localpath="${sourceRadio}" |
---|
41 | $MKDIR -p ./${localpath} |
---|
42 | cd ./${localpath} |
---|
43 | |
---|
44 | |
---|
45 | #Path of the utility scripts |
---|
46 | scriptpath=${SCRIPTPATH} |
---|
47 | |
---|
48 | |
---|
49 | #JEC 1/10/11 Use generic baodaqstatus name |
---|
50 | #get the daq current irod status |
---|
51 | #tag=`${DATE} +%F` |
---|
52 | #OUT1=${publicpath}/baodaqstatus-${tag}.txt |
---|
53 | #OUT1=${publicpath}/baodaqstatus-2011-09-11.txt |
---|
54 | OUT1=${publicpath}/baodaqstatus-current.txt |
---|
55 | |
---|
56 | |
---|
57 | if [ ! -e ${OUT1} -o ! -r ${OUT1} ]; then |
---|
58 | $ECHO "FATAL (${scriptName}): ${OUT1} is missing or not readable..." |
---|
59 | exit 1 |
---|
60 | fi |
---|
61 | |
---|
62 | if [ ! "<${sourceRadio}>" = "<>" ]; then |
---|
63 | $ECHO "You have selected sourceRadio = $sourceRadio" |
---|
64 | tableau=( `$GREP -i ${sourceRadio} ${OUT1} | $AWK '( NF==4 ) { print $2 }' ` ) |
---|
65 | else |
---|
66 | tableau=( `$CAT ${OUT1} | $GREP -i "baoradio" | $AWK '( NF==4 ) { print $2 }'` ) |
---|
67 | fi |
---|
68 | IFS=' |
---|
69 | ' |
---|
70 | tableau=( $( $PRINTF "%s\n" "${tableau[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
71 | IFS=$DefaultIFS |
---|
72 | |
---|
73 | for i in ${tableau[@]} |
---|
74 | do |
---|
75 | #scrutinize irods directory |
---|
76 | #Nb: we do not care here if ILS returns non unique instance of a file |
---|
77 | scafile=`ils -l $i 2>&1 | $GREP -i "sca[0-9][0-9]*\.[0-9][0-9]*" | $AWK '{print $NF}'` |
---|
78 | if [ "<${scafile}>" = "<>" ]; then |
---|
79 | $ECHO "INFO (${scriptName}): Cannot download a SCA file for `basename $i`" |
---|
80 | fi |
---|
81 | done |
---|