blob: 56372616b48e223515c9056bfb52ce58e8c5c3e3 (
plain)
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
|
#!/bin/bash
snapshots_dir=
verbose=false
OPTS="`getopt -l dir:,verbose: -- "$@"`"
while test $# -gt 0; do
case $1 in
--dir) snapshots_dir="$2"; shift ;;
--verbose) verbose="$2"; shift ;;
--) shift; break ;;
esac
shift
done
if $verbose; then
verbose="set -x"
else
verbose=""
fi
$verbose
if [ x"$snapshots_dir" = x"" ]; then
echo "ERROR: --dir DIR not specified"
exit 1
fi
declare -A pids
declare -A results
todo_machines="$@"
for M in $todo_machines; do
(
$verbose
rsync -az --delete $snapshots_dir-new/ $M:$snapshots_dir-new/
ssh -fn $M "flock -x $snapshots_dir.lock -c \"rsync -a --delete ${snapshots_dir}-new/ $snapshots_dir/\""
) > /tmp/update-snapshots-ref.$$.$M 2>&1 &
pids[$M]=$!
done
for M in $todo_machines; do
set +e
echo "Waiting completion for $M..."
wait ${pids[$M]}
results[$M]=$?
set -e
sed -e "s/^/$M: /" < /tmp/update-snapshots-ref.$$.$M
rm /tmp/update-snapshots-ref.$$.$M
done
all_ok="0"
for M in $todo_machines; do
if [ ${results[$M]} = 0 ]; then
result="SUCCESS"
else
result="FAILED"
all_ok="1"
fi
echo "$result: $M"
done
exit $all_ok
|