-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate_unit_report.sh
executable file
·51 lines (40 loc) · 1.18 KB
/
generate_unit_report.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
set -o errexit
date
SCRIPT=~ernie/git/utilities/unit_report.py
REPORT=~ernie/Dropbox/Web/goeverywhere/unit_report.html
if which md5 &>/dev/null
then
md5=md5
elif which md5sum &> /dev/null
then
md5=md5sum
else
# don't use checksum for cache file
#
md5=cat
fi
runtimestamp=$(date +%Y%m%d%H%M%S)
tempfile=$(mktemp /tmp/average_unit_report.XXXXXX)
trap "rm $tempfile" exit
$SCRIPT --run-timestamp "$runtimestamp" > "$tempfile"
old_md5=$(grep -v diffignore "$REPORT" | $md5)
new_md5=$(grep -v diffignore "$tempfile" | $md5)
echo "old_md5: $old_md5"
echo "new_md5: $new_md5"
if [ -s "$tempfile" -a "$old_md5" != "$new_md5" ]
then
echo "Generating new report"
echo "DIFF:"
diff "$REPORT" "$tempfile" || true
ls -l "$tempfile"
echo "old_md5: $old_md5"
echo "new_med5: $new_md5"
cp -pri "$REPORT" "$REPORT.$runtimestamp"
cat "$tempfile" > "$REPORT"
date="$(date +%Y-%m-%d)"
(echo "Updated https://goeverywhere.ernie.org/unit_report.html" ; echo ; echo ; diff "$REPORT.$runtimestamp" "$REPORT" ) | mail -s "Unit Report Update $date" unit-notifier@ernie.org
else
echo "Not generating new report"
fi
find `dirname $REPORT` -path $REPORT.\* -mtime +7 -exec rm {} \;