moth/bin/once

34 lines
681 B
Plaintext
Raw Normal View History

2015-04-10 16:37:21 -06:00
#! /bin/sh
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/*
: > state/points.log
2015-04-10 16:37:21 -06:00
fi
# Collect new points
find state/points.new -type f | while read fn; do
2015-04-18 19:13:07 -06:00
# Skip partially-written files
2015-04-19 22:57:35 -06:00
[ $(wc -l < $fn) -eq 1 ] || continue
2015-04-18 19:13:07 -06:00
2015-04-10 16:37:21 -06:00
cat $fn >> state/points.log
rm $fn
done
# Generate new puzzles.html
2015-04-21 07:57:11 -06:00
if www/cgi/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
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