chiark / gitweb /
do-slaves: Rewrite output path to prevent buffering of stderr.
[distorted-bits] / do-slaves
1 #! /bin/sh
2 set -e
3
4 ## Parse the command line.
5 case "$#" in
6   0 | 1)
7     echo >&2 "Usage: $0 COMMAND SLAVE|:SET ..."
8     exit 1
9     ;;
10 esac
11 command=$1; shift
12
13 ## Expand slaves into a big list.
14 slaves=$(expand-list /etc/slaves "$@")
15
16 ## Now do the stuff.
17 for i in $slaves; do
18   { { { echo "starting..."
19         set +e; ssh "$i" "$command" 3>&-; rc=$?; set -e
20         echo "done (rc = $rc)"; } >&3; } 2>&1 |
21     while IFS= read line; do echo "!!! $line"; done; } 3>&1 |
22   while IFS= read line; do echo "$i: $line"; done &
23 done
24 wait