Comment 4 for bug 1549319

Revision history for this message
Scott Moser (smoser) wrote : Re: server iso install prompts for postfix config

I think i'm going to change this into a bug to Suggests, not Recommends 'mta' from mdadm.
Adam Conrad, Scott Kitterman and I had some discussion on that at http://irclogs.ubuntu.com/2015/08/06/%23ubuntu-devel.html#t22:53 .

We'll change /etc/cron.daily/mdadm to use '
exec $MDADM --monitor --scan --oneshot --program=/usr/lib/mdadm/update-motd

and then have /usr/lib/mdadm/update-motd like below.
mdadm invokes the program once for each event, so to collect only the last run's events we have to do this business with statefile and the parent pid.

#!/bin/sh
# keep state in statefile and write otuput to motdfile
fail() { echo "$@" 1>&2; exit 1; }
statefile="/tmp/mydir/mystate.txt"
motdfile="/tmp/output"
[ $# -eq 0 ] && exit 0

[ -d "${statefile%/*}" ] || mkdir -p "${statefile%/*}"
parent="$PPID"
event="$1"
target="$2"
[ $# -eq 2 ] || fail "bad args for $0: $*"

# clean out any old info
echo "$parent $event $target" >> "$statefile" ||
   fail "failed writing $statefile"
sed -i "/^$parent /!d" "$statefile" || fail "failed update $statefile"

while read ppid event target; do
   echo "parent $parent said event=$event target=$target"
done < "$statefile" > "$motdfile"