diff options
author | Erich Eckner <git@eckner.net> | 2020-02-21 09:54:19 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2020-02-21 09:54:19 +0100 |
commit | 0c18fa69acb10e086514323008d153d4504c5543 (patch) | |
tree | 321f90dcfb172073e10abacedbeff09f602b3bb0 | |
parent | 9e18b08b629c69e49417fd778fafc3f0217b4cc9 (diff) | |
download | update-all-0c18fa69acb10e086514323008d153d4504c5543.tar.xz |
update-all: use -c and -s on update-me
-rw-r--r-- | update-all.in | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/update-all.in b/update-all.in index bb87ece..4f30882 100644 --- a/update-all.in +++ b/update-all.in @@ -5,7 +5,14 @@ . #ETCDIR#/update-all.conf -if [ "$#" -eq 2 ]; then +usage() { + >&2 printf 'usage:\n' + >&2 printf ' %s\n' "${0##*/}" + >&2 printf ' %s $id $tmpdir [cs]\n' "${0##*/}" + exit 1 +} + +if [ "$#" -eq 3 ]; then system="${systems["$1"]}" if [ "${system}" == "localhost" ] then @@ -14,20 +21,33 @@ if [ "$#" -eq 2 ]; then 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 + case "$3" in + 'c') + while sleep 1; do + ${cmd} -c + err=$? + if [ "${err}" -ne 1 ]; then + break + fi + done + ;; + 's') + ${cmd} -s + err=$? + if [ "${err}" -ne 0 ] \ + && [ -d "$2" ]; then + printf '%s\n' "${err}" > "$2/$1" + fi + ;; + *) + usage + ;; + esac 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 + usage fi tmp_dir=$(mktemp -d) @@ -37,10 +57,12 @@ pids=() for system in "${!systems[@]}"; do if [ -z "${DISPLAY}" ]; then - screen -S update-all -d -m "${0}" "${system}" "${tmp_dir}" + screen -S update-all -d -m "${0}" "${system}" "${tmp_dir}" 's' + screen -S update-clear-all -d -m "${0}" "${system}" "${tmp_dir}" 'c' else urxvt -title "${systems["${system}"]}: update-me" -e "${0}" "${system}" "${tmp_dir}" & pids+=($!) + screen -S update-clear-all -d -m "${0}" "${system}" "${tmp_dir}" 'c' fi done |