#! /bin/sh -e fn=$2/$3 PACKAGES=$CTF_BASE/packages STATE=$CTF_BASE/state WWW=$CTF_BASE/www POINTS=$STATE/points.log 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 for pwfile in $PACKAGES/*/password; do if [ -f $pwfile ]; then ( cat bkup.png tar cf - $STATE | gzip -c | $PACKAGES/*/bin/tea 3< $pwfile ) > $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