Verified claim.cgi, puzzled, scoreboard. Looking good.

This commit is contained in:
Neale Pickett 2011-10-13 17:22:03 -06:00
parent ffa1ce9271
commit f021ffd092
4 changed files with 41 additions and 35 deletions

View File

@ -1,4 +1,4 @@
#! /usr/bin/awk -f #! /bin/awk -f
## ##
## ##

View File

@ -1,28 +1,14 @@
#! /bin/sh #! /bin/sh
# First argument is seconds between running everything fn=$2/$3
period=${1:-60}
NEWPOINTS=/var/lib/ctf/points.new
POINTS=/var/lib/ctf/points.log POINTS=/var/lib/ctf/points.log
SCOREBOARD=/var/www/scoreboard.html SCOREBOARD=/var/www/scoreboard.html
if ! [ -f $SCOREBOARD ]; then
/opt/mcp/bin/scoreboard < $POINTS > $SCOREBOARD
fi
while true; do
# Collect any new points
for fn in $NEWPOINTS/*; do
[ -f $fn ] || continue
cat $fn >> $POINTS || break cat $fn >> $POINTS || break
rm $fn rm $fn
done
# Render scoreboard # Render scoreboard
if [ $POINTS -nt $SCOREBOARD ]; then if [ $POINTS -nt $SCOREBOARD ]; then
/opt/mcp/bin/scoreboard < $POINTS > $SCOREBOARD.new && mv $SCOREBOARD.new $SCOREBOARD /opt/mcp/bin/scoreboard < $POINTS > $SCOREBOARD.new && mv $SCOREBOARD.new $SCOREBOARD
fi fi
sleep $period
done

View File

@ -1,13 +1,37 @@
#! /bin/sh #! /bin/sh -e
exec 2>&1 exec 2>&1
install -o ctf -m 0755 -d /var/lib/ctf/points.new install -d /var/lib/ctf
# Create CTF user
touch /etc/group /etc/passwd
addgroup -g 56634 nogroup || true
adduser -D -S -h /var/lib/ctf -H ctf || true
NEWDIR=/var/lib/ctf/points.new
install -d /var/www
install -o ctf -m 0755 -d $NEWDIR
install -o ctf -m 0755 -d /var/lib/ctf/points.tmp install -o ctf -m 0755 -d /var/lib/ctf/points.tmp
touch /var/lib/ctf/points.log touch /var/lib/ctf/points.log
# Re-populate teams list for tanks # Generate preliminary scoreboard
ls $base/teams/names | KEY="Too much cheese." /opt/mcp/bin/arc4 > $www/teams.txt.$$ if ! [ -f /var/www/scoreboard.html ]; then
mv $www/teams.txt.$$ $www/teams.txt /opt/mcp/bin/scoreboard < /dev/null > /var/www/scoreboard.html
fi
exec ./pointsd
if [ -x /sbin/inotifyd ]; then
exec /sbin/inotifyd ./pointsd $NEWDIR:y
fi
# Simulate inotifyd
cd $NEWDIR
while true; do
for fn in *; do
[ -f "$fn" ] || continue
./pointsd m $NEWDIR $fn
done
sleep 7
done

View File

@ -2,14 +2,10 @@
exec 2>&1 exec 2>&1
install -d /var/www
# Install truncates files
DB=/var/lib/ctf/puzzles.db DB=/var/lib/ctf/puzzles.db
# Create CTF user
touch /etc/group /etc/passwd
addgroup -g 56634 nogroup || true
adduser -D -S -h /var/lib/ctf -H ctf || true
mkdir -p /var/lib/ctf /var/www
touch $DB touch $DB
chown ctf $DB chown ctf $DB