2015-04-10 16:37:21 -06:00
|
|
|
#! /bin/sh
|
|
|
|
|
2015-04-12 11:11:15 -06:00
|
|
|
cd $(dirname $0)/..
|
2015-04-10 16:37:21 -06:00
|
|
|
|
|
|
|
# Do nothing if `disabled` is present
|
|
|
|
if [ -f disabled ]; then
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Reset to initial state if `reset` is present
|
|
|
|
if [ -f reset ]; then
|
|
|
|
rm -f state/teams/* state/points.new/* state/points.tmp/*
|
2015-04-12 11:11:15 -06:00
|
|
|
: > state/points.log
|
2015-04-21 07:59:35 -06:00
|
|
|
rm -f reset
|
2015-04-10 16:37:21 -06:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Collect new points
|
|
|
|
find state/points.new -type f | while read fn; do
|
2015-06-06 21:17:55 -06:00
|
|
|
# Skip files opened by another process
|
|
|
|
lsof $fn | grep -q $fn && continue
|
|
|
|
|
|
|
|
# Skip partially written files
|
|
|
|
[ $(wc -l < $fn) -gt 0 ] || continue
|
2015-04-18 19:13:07 -06:00
|
|
|
|
2015-06-06 21:17:55 -06:00
|
|
|
# filter the file for unique awards
|
|
|
|
sort -k 4 $fn | uniq -f 1 | sort -n >> state/points.log
|
|
|
|
|
|
|
|
# Now kill the file
|
|
|
|
rm -f $fn
|
2015-04-10 16:37:21 -06:00
|
|
|
done
|
|
|
|
|
|
|
|
# Generate new puzzles.html
|
2015-05-26 10:14:30 -06:00
|
|
|
if www/cgi-bin/puzzles.cgi > www/puzzles.new; then
|
2015-04-10 16:37:21 -06:00
|
|
|
mv www/puzzles.new www/puzzles.html
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Generate new points.json
|
2015-04-12 11:11:15 -06:00
|
|
|
if bin/points state/points.log > www/points.new; then
|
2015-04-10 16:37:21 -06:00
|
|
|
mv www/points.new www/points.json
|
|
|
|
fi
|