-
Notifications
You must be signed in to change notification settings - Fork 0
/
dldata.sh
executable file
·95 lines (82 loc) · 2.16 KB
/
dldata.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
#!/bin/sh
set -u
set -x
usage () { # {{{
cat <<-USAGE
usage: $0 -i NODELIST -l SLICE -d REMOTEDIR
-s DOWNLOADDIR -k RSAKEY -L LOGDIR [-t TIMEOUT]
this will download ctrack-measured data on directory REMOTEDIR in all PlanetLab
nodes in the NODELIST file at DOWNLOADDIR. SLICE should be a slice name, e.g.,
upmc_ts. RSAKEY should be a RSA key that the planetlab nodes accept (e.g.,
~/.ssh/id_rsa_everywhere). TIMEOUT defaults to 300 seconds.
this script will download all data files created more than 6 hours ago. also,
we assume files are named /REMOTEDIR/prefix.%Y%m%d%H%M%S on the remote hosts.
USAGE
exit 1
} # }}}
slice=invalid
nodelist=invalid
remotedir=invalid
dldir=invalid
rsakey=invalid
logdir=invalid
timeout=300
while getopts "i:l:d:s:t:k:L:h" OPTNAME ; do # {{{
case $OPTNAME in
i)
nodelist=$OPTARG
;;
l)
slice=$OPTARG
;;
d)
remotedir=$OPTARG
;;
s)
dldir=$OPTARG
;;
t)
timeout=$OPTARG
;;
k)
rsakey=$OPTARG
;;
L)
logdir=$OPTARG
;;
h|*)
usage
;;
esac
done
shift $(expr $OPTIND - 1)
OPTIND=1 # }}}
test $slice != invalid || usage
test $nodelist != invalid || usage
test $remotedir != invalid || usage
test $dldir != invalid || usage
test $logdir != invalid || usage
if [ ! -f $rsakey ] ; then echo "RSA key not found." ; exit 1 ; fi
if [ ! -f $nodelist ] ; then echo "nodelist not found." ; exit 1 ; fi
mkdir -p $dldir
BASECMD="/home/cunha/bin/vxargs -pr -a $nodelist -y" ;
$BASECMD -t 10 mkdir -p $dldir/{}
$BASECMD -t 20 ssh -i $rsakey $slice@{} sudo chmod 777 -R $remotedir
$BASECMD -t 20 -o $logdir/dllist/ ssh -i $rsakey $slice@{} \
find $remotedir -type f
basedate=$(\date -u -d "-3 day" +"%Y%m%d%H%M%S")
cat $nodelist | while read hostname ; do
rm -f $logdir/dllist/$hostname.list
cat $logdir/dllist/$hostname.out | while read filename ; do
filedate=$(basename $filename)
filedate=${filedate##*.}
echo $filedate $basedate
if [ $filedate -lt $basedate ] ; then
echo $filename >> $logdir/dllist/$hostname.list
fi
done
done
$BASECMD -P 10 -t $timeout -o $logdir/dl/ rsync -auvz --append \
--remove-source-files \
--no-relative --files-from $logdir/dllist/{}.list \
--rsh "ssh -i $rsakey" $slice@{}:/ $dldir/{}/