#!/bin/sh
#
# Bring the autobuild website status up-to-date.
# This script is called by the build_on_system scripts,
# which run simultaniously, so this script needs to be 
# reentrant.
# Orion Sky Lawlor, olawlor@acm.org, 2002/2/3
#

source config

# Exit giving this reason for failure.
Die() {
	echo "email fatal> " $@ 
	exit 1
}

# Run this command or die
Do() {
	echo "email> " $@
	$@ 
	err="$?"
	if [ $err -ne 0 ] 
	then
		Die "error code $err during " $@ 
	fi
}

versions=`awk -F: '{print $1}' system_list`

status="status/email"
rm $status

for v in $versions
do
	echo "$v:" `cat status/$v` >> $status
done

cat >> $status << END_OF_TRAILER
Autobuild ran on `date`
See the detailed results at:
  http://charm.cs.uiuc.edu/autobuild/cur/
Contact olawlor@acm.org to be removed from this list.
END_OF_TRAILER

cat $status | mail -s "Charm++ Autobuild Status" $mailRecip
echo "Message sent to $mailRecip"
