/[pdpsoft]/trunk/nl.biggrid.dans/list-archive.sh
ViewVC logotype

Annotation of /trunk/nl.biggrid.dans/list-archive.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2582 - (hide annotations) (download) (as text)
Tue Nov 20 12:07:59 2012 UTC (9 years, 10 months ago) by svn
File MIME type: application/x-shellscript
File size: 2615 byte(s)
First released version
1 svn 2582 #!/bin/bash
2    
3     argv=$@
4     date +"%Y/%m/%d-%H:%M:%S Job start: [$argv]"
5    
6     if [ $# -lt 3 ]
7     then
8     echo "Wrong number of parameters for job. Need at least 3." 1>&2
9     echo "Usage: $0 ARCHIVE START_INDEX END_INDEX" 1>&2
10     echo "Aborting" 1>&2
11     exit 1
12     fi
13    
14     archive="$1"
15     vo=dans
16     export LFC_HOST=lfc.grid.sara.nl
17     export LFC_HOME="/grid/${vo}/${archive}"
18     export SRM_TIMEOUTS="--connect-timeout 14400 --sendreceive-timeout 14400 --srm-timeout 14400"
19     export SRM_HOME="srm://srm.grid.sara.nl/pnfs/grid.sara.nl/data/${vo}/${archive}"
20    
21     # make sure the sorting is done using a well-defined locale
22     export LC_ALL=C
23    
24     i=$2 # start_index
25     end_index=$3
26    
27     # figure out the number of digits in the archives by looking at the first one
28     num_digits=3
29     lfcpath=`printf "${LFC_HOME}/${archive}-%0${num_digits}d.tar.gz" $i`
30     if ! lfc-ls "${lfcpath}" > /dev/null 2>&1
31     then
32     num_digits=4
33     lfcpath=`printf "${LFC_HOME}/${archive}-%0${num_digits}d.tar.gz" $i`
34     if ! lfc-ls "${lfcpath}" > /dev/null 2>&1
35     then
36     num_digits=5
37     lfcpath=`printf "${LFC_HOME}/${archive}-%0${num_digits}d.tar.gz" $i`
38     if ! lfc-ls "${lfcpath}" > /dev/null 2>&1
39     then
40     echo "Cannot find first archive! Tried using 3, 4 and 5 digits"
41     echo "Aborting" 1>&2
42     exit 2
43     fi
44     fi
45     fi
46    
47     # start with a clean slate
48     rm -rf workspace adler32sums.txt md5sums.txt
49    
50     while [ $i -le ${end_index} ]
51     do
52     base=`printf "${archive}-%0${num_digits}d.tar" $i`
53     file="${base}.gz"
54    
55     echo "Retrieving file lfn:/${LFC_HOME}/$file"
56     lcg-cp $SRM_TIMEOUTS lfn:/${LFC_HOME}/$file file://$PWD/$file
57     if [ $? -ne 0 ]
58     then
59     echo "First attempt failed, sleeping 30 seconds and retrying..." 1>&2
60     sleep 30
61     lcg-cp $SRM_TIMEOUTS lfn:/${LFC_HOME}/$file file://$PWD/$file
62     fi
63     if [ $? -ne 0 ]
64     then
65     echo "Second attempt failed, sleeping 90 seconds and retrying..." 1>&2
66     sleep 90
67     date +"%Y/%m/%d-%H:%M:%S start lcg-cp -v -v $SRM_TIMEOUTS" 1>&2
68     lcg-cp -v -v $SRM_TIMEOUTS lfn:/${LFC_HOME}/$file file://$PWD/$file
69     fi
70     if [ $? -ne 0 ]
71     then
72     echo "Error retrieving lfn:/${LFC_HOME}/$file" 1>&2
73     echo "Aborting" 1>&2
74     exit 3
75     fi
76    
77     echo "# ${base} START" > "${base}.lst"
78     tar tzvf $file >> "${base}.lst"
79     echo "# ${base} END" >> "${base}.lst"
80    
81     # delete the tar ball and clear out the workspace
82     rm -rf $file workspace
83     let i=i+1
84     done
85    
86     # now pack all *.mdsum files together; this is what is returned in the output sandbox
87     tar czvf contents.tar.gz ${archive}*.lst
88    
89     date +"%Y/%m/%d-%H:%M:%S Job end"
90    

Properties

Name Value
svn:executable *

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28