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

This commit is contained in:
Neale Pickett 2011-10-13 17:22:03 -06:00
parent 02b9884709
commit 46404a3667
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
# First argument is seconds between running everything
period=${1:-60}
NEWPOINTS=/var/lib/ctf/points.new
fn=$2/$3
POINTS=/var/lib/ctf/points.log
SCOREBOARD=/var/www/scoreboard.html
if ! [ -f $SCOREBOARD ]; then
/opt/mcp/bin/scoreboard < $POINTS > $SCOREBOARD
cat $fn >> $POINTS || break
rm $fn
# Render scoreboard
if [ $POINTS -nt $SCOREBOARD ]; then
/opt/mcp/bin/scoreboard < $POINTS > $SCOREBOARD.new && mv $SCOREBOARD.new $SCOREBOARD
fi
while true; do
# Collect any new points
for fn in $NEWPOINTS/*; do
[ -f $fn ] || continue
cat $fn >> $POINTS || break
rm $fn
done
# Render scoreboard
if [ $POINTS -nt $SCOREBOARD ]; then
/opt/mcp/bin/scoreboard < $POINTS > $SCOREBOARD.new && mv $SCOREBOARD.new $SCOREBOARD
fi
sleep $period
done

View File

@ -1,13 +1,37 @@
#! /bin/sh
#! /bin/sh -e
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
touch /var/lib/ctf/points.log
# Re-populate teams list for tanks
ls $base/teams/names | KEY="Too much cheese." /opt/mcp/bin/arc4 > $www/teams.txt.$$
mv $www/teams.txt.$$ $www/teams.txt
# Generate preliminary scoreboard
if ! [ -f /var/www/scoreboard.html ]; then
/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
install -d /var/www
# Install truncates files
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
chown ctf $DB