-
Notifications
You must be signed in to change notification settings - Fork 0
/
pnfs_untar_tardir.sh
executable file
·105 lines (80 loc) · 2 KB
/
pnfs_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
#!/bin/bash
# Test script to untar $INPUT_TAR_FILE and list its contents
# To be used with --tar_file_name directives
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 "--testtar <tarball_name> What name of tarball we should be looking for"
echo "--secondtesttar <tarball_name> In case of multiple tarfiles, name of second dir"
echo "-h|--help Print this message and exit"
exit $EXITCODE
}
# Begin main
echo "Starting run now"
# Parse args
while (( "$#" )); do
case "$1" in
-e)
shift
EXPERIMENT=$1
shift
;;
-h|--help)
usage
;;
*)
echo "Error: unsupported flag $1" >&2
usage 1
;;
esac
done
# Checks
# echo "${INPUT_TAR_FILE?INPUT_TAR_FILE not set}"
# Defaults
# Assume nova if no expt given
if [[ -z ${EXPERIMENT+x} ]];
then
EXPERIMENT=nova
fi
SCRATCHDIR="/pnfs/${EXPERIMENT}/scratch/users/sbhat"
. /cvmfs/fermilab.opensciencegrid.org/products/common/etc/setups.sh
setup ifdhc
set -e
# Show tar contents
echo "If you used --tar_file_name to submit, the tarball will be unwound here:"
ls -Rl ${_CONDOR_JOB_IWD}
ls
echo ""
echo "Peek inside the tarball"
if [[ -n ${INPUT_TAR_FILE+x} ]];
then
tar -tvf ${INPUT_TAR_FILE}
fi
echo ""
echo "If you used -f, the tarfiles live in \$CONDOR_DIR_INPUT, but not unwound:"
if [[ -n ${CONDOR_DIR_INPUT+x} ]];
then
ls -Rl ${CONDOR_DIR_INPUT}
echo "Peek inside the tarballs"
for TARBALL in `find ${CONDOR_DIR_INPUT} -type f -name "*.tar"`;
do
echo "Peek inside $TARBALL"
tar -tvf $TARBALL
echo ""
done
fi
echo "Creating a new file to copy out"
DATE=`date +%s`
FILENAME="outfile_${DATE}"
ls -Rl ${_CONDOR_JOB_IWD} > ${_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
exit 0