forked from amplab/spark-ec2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy-dir.sh
executable file
·49 lines (40 loc) · 775 Bytes
/
copy-dir.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
#!/bin/bash
DELETE_FLAG=""
usage() {
echo "Usage: copy-dir [--delete] <dir>"
exit 1
}
while :
do
case $1 in
--delete)
DELETE_FLAG="--delete"
shift
;;
-*)
echo "ERROR: Unknown option: $1" >&2
usage
;;
*) # End of options
break
;;
esac
done
if [[ "$#" != "1" ]] ; then
usage
fi
if [[ ! -e "$1" ]] ; then
echo "File or directory $1 doesn't exist!"
exit 1
fi
DIR=`readlink -f "$1"`
DIR=`echo "$DIR"|sed 's@/$@@'`
DEST=`dirname "$DIR"`
SLAVES=`cat /root/spark-ec2/slaves`
SSH_OPTS="-o StrictHostKeyChecking=no -o ConnectTimeout=5"
echo "RSYNC'ing $DIR to slaves..."
for slave in $SLAVES; do
echo $slave
rsync -e "ssh $SSH_OPTS" -az $DELETE_FLAG "$DIR" "$slave:$DEST" & sleep 0.5
done
wait