diff options
author | Erich Eckner <git@eckner.net> | 2019-11-08 07:54:21 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2019-11-08 07:55:09 +0100 |
commit | cf8597ed38c808f717db86a42689c0b483b8487a (patch) | |
tree | b47a96a3d6c54c8a23f1fe3d000577fd5f039e7a | |
parent | 54f4f5902c282696eef9df8d36baaa5f869df5eb (diff) | |
download | update-all-cf8597ed38c808f717db86a42689c0b483b8487a.tar.xz |
update-all.in: give summary report at the end
-rw-r--r-- | update-all.in | 58 |
1 files changed, 54 insertions, 4 deletions
diff --git a/update-all.in b/update-all.in index 9136058..7074c42 100644 --- a/update-all.in +++ b/update-all.in @@ -5,8 +5,8 @@ . #ETCDIR#/update-all.conf -for system in "${systems[@]}" -do +if [ "$#" -eq 2 ]; then + system="${systems["$1"]}" if [ "${system}" == "localhost" ] then cmd="" @@ -14,9 +14,59 @@ do cmd="ssh -t -t ${system}" fi cmd="${cmd} update-me" + ${cmd} + err=$? + if [ "${err}" -ne 0 ] \ + && [ -d "$2" ]; then + printf '%s\n' "$?" > "$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 ${cmd} + screen -S update-all -d -m "'$0' '${system}' '${tmp_dir}'" else - urxvt -title "${system}: update-me" -e ${cmd} & + 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 +) |