blob: c82ebc61b5c4f4714c5f82519f157fb07b3c0cac (
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
65
66
67
68
69
70
71
72
|
#!/bin/bash
# update-all version #VERSION#
# updates all clients defined in #ETCDIR#/update-all.conf via local versions of update-me
. #ETCDIR#/update-all.conf
if [ "$#" -eq 2 ]; then
system="${systems["$1"]}"
if [ "${system}" == "localhost" ]
then
cmd=""
else
cmd="ssh -t -t ${system}"
fi
cmd="${cmd} update-me"
${cmd}
err=$?
if [ "${err}" -ne 0 ] \
&& [ -d "$2" ]; then
printf '%s\n' "${err}" > "$2/$1"
fi
exit ${err}
fi
if [ "$#" -ne 0 ]; then
>&2 printf 'usage:\n'
>&2 printf ' %s\n' "${0##*/}"
>&2 printf ' %s $id $tmpdir\n' "${0##*/}"
exit 1
fi
tmp_dir=$(mktemp -d)
trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT
pids=()
for system in "${!systems[@]}"; do
if [ -z "${DISPLAY}" ]; then
screen -S update-all -d -m "${0}" "${system}" "${tmp_dir}"
else
urxvt -title "${systems["${system}"]}: update-me" -e "${0}" "${system}" "${tmp_dir}" &
pids+=($!)
fi
done
if [ -z "${DISPLAY}" ]; then
pids=$(
screen -list \
| sed '
s/^\s\+\([0-9]\+\)\.update-all\s.*$/\1/
t
d
'
)
fi
while kill -0 "${pids[@]}"; do
sleep 1
done
ls "${tmp_dir}" \
| while read -r system; do
printf 'update-me on %s ("%s") failed\n' \
"${system}" \
"${systems["${system}"]}"
done
exit $(
ls "${tmp_dir}" \
| wc -l
)
|