summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--update-all.in46
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