#! /bin/sh -e fn=$2/$3 WWW=${CTF_BASE:-/var/www} BASE=${CTF_BASE:-/var/lib/ctf} OPT=${CTF_BASE:-/opt} POINTS=$BASE/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 $OPT/*/password; do if [ -f $pwfile ]; then ( cat bkup.png tar cf - $BASE | gzip -c | $OPT/*/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