-
Notifications
You must be signed in to change notification settings - Fork 0
/
rcds_untar_tardir.sh
executable file
·115 lines (88 loc) · 2.43 KB
/
rcds_untar_tardir.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/sh
# This test job tests a simple read from the Rapid Code Distribution service. If we specify that our tarball is called "TestDir.tar", then in the job, we expect to find the tarball
# untarred at ${CONDOR_DIR_INPUT}/TestDir/
# We will then try to copy a combined file back to scratch dCache --- Note that we're assuming this is a Nova job, unless otherwise specified
# Submit this job with an incantation like:
# jobsub_submit -G nova --resource-provides=usage_model=DEDICATED,OFFSITE --expected-lifetime='short' --tar_file_name=dropbox:///path/to/TestDir.tar --use-cvmfs-dropbox file:///path/to/cvmfs_untar.sh
#
function usage {
EXITCODE=$1
if [-z ${EXITCODE+x} ];
then
EXITCODE=0
fi
echo "Usage FILL THIS IN"
echo "-e <experiment> Which experiment's scratch area to write test file to"
echo "--testdir <dir> What name of RCDS dir we should be looking for"
echo "--secondtestdir <dir> In case of multiple tarfiles, name of second dir"
echo "-h|--help Print this message and exit"
exit $EXITCODE
}
function cat_contents {
# For a directory, dump the file name and contents of all files contained within
DIR=$1
find $DIR -type f -exec sh -c "echo {} ; cat {}; echo '""'" \;
}
# Begin main
while (( "$#" )); do
case "$1" in
-e)
shift
EXPERIMENT=$1
shift
;;
--testdir)
shift
TESTDIR=$1
shift
;;
--secondtestdir)
shift
SECONDTESTDIR=$1
shift
;;
-h|--help)
usage
;;
*)
echo "Error: unsupported flag $1" >&2
usage 1
;;
esac
done
# Defaults
# Assume nova if no expt given
if [[ -z ${EXPERIMENT+x} ]];
then
EXPERIMENT=nova
fi
if [[ -z ${TESTDIR+x} ]];
then
TESTDIR=TestDir
fi
SCRATCHDIR="/pnfs/${EXPERIMENT}/scratch/users/sbhat"
. /cvmfs/fermilab.opensciencegrid.org/products/common/etc/setups.sh
setup ifdhc
set -e
echo "Testing Rapid Code Distribution"
TARDIR=${CONDOR_DIR_INPUT}/${TESTDIR}/
ls $TARDIR
echo ""
cat_contents ${TARDIR}
if [[ -n ${SECONDTESTDIR+x} ]];
then
echo "Second Test Dir"
SECONDTARDIR=${CONDOR_DIR_INPUT}/${SECONDTESTDIR}/
ls $SECONDTARDIR
echo ""
cat_contents ${SECONDTESTDIR}
fi
echo "Creating a new file to copy out"
DATE=`date +%s`
FILENAME="combined_file_${DATE}"
cat ${TARDIR}/a ${TARDIR}/b ${TARDIR}/c > ${_CONDOR_JOB_IWD}/${FILENAME}
DESTPATH=${SCRATCHDIR}/${FILENAME}
echo "Copying file out to $DESTPATH"
ifdh cp ${_CONDOR_JOB_IWD}/${FILENAME} $DESTPATH
echo "Copy Successful. Going to sleep."
sleep 300