2010-03-02 20:45:21 -07:00
|
|
|
#! /bin/sh
|
|
|
|
|
2010-03-06 22:19:20 -07:00
|
|
|
# First argument is seconds between running everything
|
2010-09-13 17:32:51 -06:00
|
|
|
period=${1:-60}
|
2010-03-06 22:19:20 -07:00
|
|
|
|
2010-09-13 17:32:51 -06:00
|
|
|
CTF_BASE=${CTF_BASE:-/srv/ctf} export CTF_BASE
|
2010-03-02 20:45:21 -07:00
|
|
|
|
2010-09-13 17:32:51 -06:00
|
|
|
POINTS=$CTF_BASE/points.log
|
|
|
|
SCOREBOARD=$CTF_BASE/www/scoreboard.html
|
|
|
|
PUZZLES=$CTF_BASE/www/puzzles.html
|
2010-03-06 22:19:20 -07:00
|
|
|
|
2010-03-02 20:45:21 -07:00
|
|
|
while true; do
|
|
|
|
start=$(date +%s)
|
2010-09-13 17:32:51 -06:00
|
|
|
next=$(expr $start + $period)
|
2010-03-02 20:45:21 -07:00
|
|
|
|
|
|
|
# Collect any new points
|
2010-09-13 17:32:51 -06:00
|
|
|
for fn in $CTF_BASE/points.new/*; do
|
2010-03-02 20:45:21 -07:00
|
|
|
[ -f $fn ] || continue
|
|
|
|
cat $fn >> $POINTS || break
|
|
|
|
rm $fn
|
|
|
|
done
|
|
|
|
|
2010-09-13 17:32:51 -06:00
|
|
|
if [ $POINTS -nt $SCOREBOARD ]; then
|
|
|
|
$CTF_BASE/sbin/scoreboard < $POINTS > $SCOREBOARD.new
|
|
|
|
mv $SCOREBOARD.new $SCOREBOARD
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $CTF_BASE/puzzler.db -nt $PUZZLES ]; then
|
|
|
|
$CTF_BASE/sbin/puzzles.cgi > $PUZZLES.new
|
|
|
|
mv $PUZZLES.new $PUZZLES
|
2010-03-02 20:45:21 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
now=$(date +%s)
|
|
|
|
if [ $now -lt $next ]; then
|
|
|
|
sleep $(expr $next - $now)
|
|
|
|
fi
|
|
|
|
done
|