-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpush
More file actions
executable file
·45 lines (35 loc) · 741 Bytes
/
push
File metadata and controls
executable file
·45 lines (35 loc) · 741 Bytes
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
#!/bin/bash
set -e
set -u
function usage() {
echo "usage: $(basename "$0") [-v] <target> [<target>...] <user@remote>"
exit 1
}
if [[ -z "${APPLY_ROOT:-}" ]]; then
APPLY_ROOT="."
fi
if [[ $# -lt 1 ]]; then
usage
fi
if [[ "$1" == "-v" ]]; then
vflag='-v'
shift
else
vflag=''
fi
if [[ $# -lt 2 ]]; then
usage
fi
targets=()
while [[ $# -gt 1 ]]; do
targets+=("$1")
shift
done
remote="$1"
tmp=$(ssh "$remote" 'mktemp -d')
echo -e -n "\033[33m** pushing to\033[0m $remote:$tmp"
if scp -q -r "${APPLY_ROOT}"/{groups,units} run lib "$remote":"$tmp"; then
echo -e " \033[32mOK\033[0m"
fi
# shellcheck disable=SC2029
ssh -A "$remote" "cd '$tmp' && ./run $vflag ${targets[*]} && cd; rm -rf '$tmp'"