/[pdpsoft]/trunk/nl.biggrid.dans/upload-tar
ViewVC logotype

Contents of /trunk/nl.biggrid.dans/upload-tar

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2582 - (show annotations) (download)
Tue Nov 20 12:07:59 2012 UTC (9 years, 8 months ago) by svn
File size: 3503 byte(s)
First released version
1 #!/bin/bash
2
3 if [ ! "x$0" = "x${0#-}" ]
4 then
5 echo "Don't source me, just run!" 1>&2
6 return
7 fi
8 . ${0%/*}/libdans.sh
9
10 # Load global defaults (vars: vo, ARCHIVE, LFC_*, SRM_*)
11 loadDefaults $0
12
13 DEBUG=0
14 QUIET=0
15 KEEPGOING=0
16 SCRATCHDIR=/data/vancis2109/grid
17 USAGE="\
18 $0 - upload the .tar tarballs of the DANS archive '${ARCHIVE}'
19 Usage: ./upload-tar [-q|--quiet] [-d|--debug] [-k|--keepgoing] [--scratchdir dir]
20 Where:
21 --keepgoing tells $0 to keep going after an error
22 --scratchdir=dir specifies the directory where the temporary tarballs are stored
23 (default='${SCRATCHDIR}')
24 "
25
26 # Parse commandline parameters
27 while [ $# -gt 0 ]
28 do
29 case "$1" in
30 (-h|--help) echo "${USAGE}"
31 exit 0
32 ;;
33 (-d|--debug) let DEBUG+=1
34 ;;
35 (-q|--quiet) QUIET=1
36 ;;
37 (-k|--keepgoing) KEEPGOING=1
38 ;;
39 (--scratchdir) SCRATCHDIR=$2
40 shift
41 ;;
42 (--scratchdir=*) SCRATCHDIR=${1##--scratchdir=}
43 ;;
44 (-*) echo "Invalid option: $1"
45 exit 1
46 ;;
47 esac
48 shift
49 done
50
51 # Verify that we have a valid proxy before continuing
52 checkProxy "${vo}"
53
54 # Verify that the scratch directory exists and that we have write access in it
55 if [ ! -d "${SCRATCHDIR}/." ]
56 then
57 abort 1 "Scratch directory '${SCRATCHDIR}' does not exist!"
58 fi
59 if [ ! -w ${SCRATCHDIR} ]
60 then
61 abort 2 "No write access in scratch directory '${SCRATCHDIR}'!"
62 fi
63
64 # Verify that we can write in the current directory, and create the 'done' directory
65 if [ ! -w ${PWD} ]
66 then
67 abort 3 "No write access in current directory '${PWD}'!"
68 fi
69 mkdir -p ./done
70 if [ ! -d ./done ]
71 then
72 abort 4 "Cannot create 'done' directory in current directory!"
73 fi
74
75 # Create the LFC directory for this archive, if it does not exist
76 lfc-ls "${LFC_HOME}" > /dev/null 2>&1
77 if [ $? -ne 0 ]
78 then
79 lfc-mkdir "${LFC_HOME}"
80 if [ $? -ne 0 ]
81 then
82 abort 5 "Error creating LFC directory '${LFC_HOME}'"
83 fi
84 fi
85
86 # Update the permissions of the LFC directory (disallow 'other' access)
87 lfc-setacl -m d:o:0,o:0 "${LFC_HOME}"
88 if [ $? -ne 0 ]
89 then
90 warn "Could not update the permissions of the LFC directory '${LFC_HOME}'"
91 fi
92
93 # Now, process all ARCHIVE-nnnn.tar.lst files in the current dir
94 for i in ${ARCHIVE}-*.tar.lst
95 do
96 tarball=${i%.lst}
97
98 info "Checksumming tarball contents"
99 echo "# ${tarball} START" > ${tarball}.md5sum
100 # work around files with spaces in them
101 while read line ; do md5sum "$line" ; done < $i >> ${tarball}.md5sum
102 echo "# ${tarball} END" >> ${tarball}.md5sum
103
104 info "Generating ${tarball}"
105 tar -c -T "$i" -f ${SCRATCHDIR}/${tarball}
106
107 info "Uploading ${tarball}"
108 lcg-cr ${SRM_TIMEOUTS} -d "${SRM_HOME}/${tarball}" -l "${LFC_HOME}/${tarball}" file://${SCRATCHDIR}/${tarball}
109 if [ $? -ne 0 ]
110 then
111 echo "First attempt failed, retrying..." 1>&2
112 lcg-cr ${SRM_TIMEOUTS} -d "${SRM_HOME}/${tarball}" -l "${LFC_HOME}/${tarball}" file://${SCRATCHDIR}/${tarball}
113 fi
114 if [ $? -ne 0 ]
115 then
116 echo "Second attempt failed, skipping to next" 1>&2
117 else
118 info "Moving $i and ${tarball}.md5sum to directory \"done\""
119 mv $i ${tarball}.md5sum done/.
120 fi
121
122 rm -f ${SCRATCHDIR}/${tarball}
123 done
124

Properties

Name Value
svn:executable

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