|
@@ -1,91 +0,0 @@
|
1
|
|
-#!/bin/bash
|
2
|
|
-
|
3
|
|
-. $(ffoom path)
|
4
|
|
-
|
5
|
|
-ffoo import pretty
|
6
|
|
-ffoo import recon
|
7
|
|
-
|
8
|
|
-ORDER="$(saturnin conf -p push.options.order)"
|
9
|
|
-
|
10
|
|
-usage() {
|
11
|
|
- usage_is "[-o|--order path:host|host:path] host..."
|
12
|
|
-}
|
13
|
|
-
|
14
|
|
-while true; do case $1 in
|
15
|
|
- -o|--order) ORDER=$2; shift 2 ;;
|
16
|
|
- --help) usage ;;
|
17
|
|
- -*) usage ;;
|
18
|
|
- "") break ;;
|
19
|
|
- *) hosts="$1"; shift ;;
|
20
|
|
-esac done
|
21
|
|
-
|
22
|
|
-test -n "$hosts" || hosts=$(saturnin conf -s push.hosts | debug_pipe ini_hosts)
|
23
|
|
-debug -v hosts
|
24
|
|
-
|
25
|
|
-test -n "$hosts" || die "no valid hosts to begin with"
|
26
|
|
-paths=$(saturnin conf -s push.paths)
|
27
|
|
-test -n "$paths" || die "no valid paths to begin with"
|
28
|
|
-
|
29
|
|
-think "Probing & sorting paths"
|
30
|
|
-paths=$(echo "$paths" \
|
31
|
|
- | expand_tilde \
|
32
|
|
- | filter test -e \
|
33
|
|
- | sort_paths_by_age \
|
34
|
|
- | debug_pipe ok_paths
|
35
|
|
- )
|
36
|
|
-test -n "$paths" || die "no valid paths"
|
37
|
|
-
|
38
|
|
-think "Probing hosts"
|
39
|
|
-hosts=$(echo "$hosts" | filter_hosts -s | debug_pipe ok_hosts )
|
40
|
|
-test -n "$hosts" || die "no valid hosts"
|
41
|
|
-
|
42
|
|
-test "$(wc -l <<<"$paths")" == 1 && ORDER="path:host"
|
43
|
|
-test "$(wc -l <<<"$hosts")" == 1 && ORDER="host:path"
|
44
|
|
-
|
45
|
|
-think "Pushing (${ORDER/:/, then })..."
|
46
|
|
-
|
47
|
|
-debug -v "paths:hosts"
|
48
|
|
-
|
49
|
|
-case "$ORDER" in
|
50
|
|
-
|
51
|
|
- "path:host")
|
52
|
|
- for path in $paths;
|
53
|
|
- do
|
54
|
|
- for host in $hosts;
|
55
|
|
- do
|
56
|
|
- if rsync -L -r --delete $path $host:
|
57
|
|
- then
|
58
|
|
- think "$(collapse_tilde <<<"$path") sent to $host"
|
59
|
|
- fi
|
60
|
|
- done
|
61
|
|
- done
|
62
|
|
- ;;
|
63
|
|
-
|
64
|
|
- "host:path")
|
65
|
|
- for host in $hosts;
|
66
|
|
- do
|
67
|
|
- for path in $paths;
|
68
|
|
- do
|
69
|
|
- if rsync -L -r --delete $path $host:
|
70
|
|
- then
|
71
|
|
- think "$host got $path"
|
72
|
|
- fi
|
73
|
|
- done
|
74
|
|
- done
|
75
|
|
- ;;
|
76
|
|
-
|
77
|
|
- *)
|
78
|
|
- die "unknown push order: '$ORDER'"
|
79
|
|
- ;;
|
80
|
|
-esac
|
81
|
|
-
|
82
|
|
-for host in $hosts;
|
83
|
|
-do
|
84
|
|
- saturnin conf -s push.commands \
|
85
|
|
- | grep . \
|
86
|
|
- | while read cmd;
|
87
|
|
- do
|
88
|
|
- think "ssh $host -- $cmd"
|
89
|
|
- ssh -n $host -- "$cmd" > /dev/null
|
90
|
|
- done
|
91
|
|
-done
|