#! /bin/sh

: ${bg="& sleep 2"}
: ${ssh=/n/net/bin/ssh}
: ${rsync=/n/utils/bin/rsync}
: ${remote_rsync="$rsync"}
: ${master=emilia}

cd $HOME/conf || exit 1

if test -z "${no_cvs_update+set}"; then
  echo "Updating with CVS" >&2
  CVS_RSH="$ssh" cvs -q update -d
  echo "Type ^C now to abort..." >&2
  sleep 1
fi

echo "Propagating configuration..." >&2

if test $# = 0; then
    set $master `cat hosts.equiv | grep -v "^$master$"`
fi

if test x"$1" = x"$master"; then
    echo $1... >&2
    shift
    ./daily
fi    

for h
do
  echo $h... >&2
  eval '
    $rsync --rsync-path="${remote_rsync}" --rsh="$ssh" \
      -ar --delete ./ $h:conf/ &&
    $ssh -n $h "cd conf && ./daily" \
  '" $bg"
done
