- if [[ $HOSTNAME != "$MAIL_HOST" ]] && $cron ; then
- echo "MAIL_HOST=$MAIL_HOST, nothing to do"
- mexit 0
- else
- amy=true
+ if $cron; then
+ if [[ $HOSTNAME != "$MAIL_HOST" ]]; then
+ if $kd_spread_maybe && [[ $HOSTNAME == kd && $MAIL_HOST == x3 ]]; then
+ if ping -q -c1 -w1 x3.office.fsf.org &>/dev/null; then
+ work_host=x3.office.fsf.org
+ elif ping -q -c1 -w1 x3wg.b8.nz &>/dev/null; then
+ work_host=x3wg.b8.nz
+ fi
+ if [[ $work_host ]]; then
+ source_state="$(ssh $work_host cat /a/bin/bash_unpublished/source-state)"
+ eval "$source_state"
+ if [[ $MAIL_HOST == x3 ]]; then
+ kd_spread=true
+ else
+ # x3 was the mail host, but it moved to some other machine
+ # without updating us yet.
+ echo "MAIL_HOST=$MAIL_HOST, nothing to do"
+ mexit 0
+ fi
+ else
+ echo "MAIL_HOST=$MAIL_HOST, nothing to do"
+ mexit 0
+ fi
+ else
+ echo "MAIL_HOST=$MAIL_HOST, nothing to do"
+ mexit 0
+ fi
+ fi