2012-06-12 18:25:32 -06:00
|
|
|
#! /bin/sh -e
|
|
|
|
|
|
|
|
fn=$2/$3
|
|
|
|
|
2012-07-22 17:14:06 -06:00
|
|
|
PACKAGES=$CTF_BASE/packages
|
|
|
|
STATE=$CTF_BASE/state
|
|
|
|
WWW=$CTF_BASE/www
|
2012-06-12 18:25:32 -06:00
|
|
|
|
2012-07-22 17:14:06 -06:00
|
|
|
POINTS=$STATE/points.log
|
2012-06-12 18:25:32 -06:00
|
|
|
BACKUP=$WWW/backup.png
|
|
|
|
SCOREBOARD=$WWW/scoreboard.html
|
|
|
|
PUZZLES=$WWW/puzzles.html
|
|
|
|
|
|
|
|
# Only do this if this score hasn't yet been recorded
|
|
|
|
if [ -n "$(sort -k2 $POINTS $fn | uniq -f1 -d)" ]; then
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Append point. pointsd is called serially from inotify,
|
|
|
|
# so we don't need to lock it.
|
|
|
|
cat $fn >> $POINTS
|
|
|
|
rm $fn
|
|
|
|
|
|
|
|
# Generate new backup if we can find a password file
|
2012-07-22 17:14:06 -06:00
|
|
|
for pwfile in $PACKAGES/*/password; do
|
2012-06-12 18:25:32 -06:00
|
|
|
if [ -f $pwfile ]; then
|
|
|
|
(
|
|
|
|
cat bkup.png
|
2012-07-22 17:14:06 -06:00
|
|
|
tar cf - $STATE | gzip -c | $PACKAGES/*/bin/tea 3< $pwfile
|
2012-06-12 18:25:32 -06:00
|
|
|
) > $BACKUP.new
|
|
|
|
mv $BACKUP.new $BACKUP
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Render scoreboard
|
|
|
|
./mkpage scoreboard < $POINTS > $SCOREBOARD.new
|
|
|
|
mv $SCOREBOARD.new $SCOREBOARD
|
|
|
|
|
|
|
|
# Render puzzles list
|
|
|
|
./mkpage puzzles.cgi > $PUZZLES.new
|
|
|
|
mv $PUZZLES.new $PUZZLES
|
|
|
|
|