moth/packages/00common/service/pointsd/run

46 lines
969 B
Plaintext
Raw Normal View History

#! /bin/sh -e
exec 2>&1
2012-07-22 17:14:06 -06:00
STATE=$CTF_BASE/state
WWW=$CTF_BASE/www
# Create CTF and nobody users
touch /etc/group /etc/passwd
addgroup -g 65534 nogroup || true
adduser -DH -G nogroup -u 65534 nobody || true
adduser -DHS ctf || true
# Set up base directories
2012-07-22 17:14:06 -06:00
NEWDIR=$STATE/points.new
TMPDIR=$STATE/points.tmp
install -o ctf -m 0755 -d $NEWDIR
install -o ctf -m 0755 -d $TMPDIR
# Create some files
2012-07-22 17:14:06 -06:00
touch $STATE/points.log
# Generate preliminary scoreboard
2012-07-22 17:14:06 -06:00
if [ ! -f $WWW/scoreboard.html ]; then
./mkpage scoreboard < /dev/null > $WWW/scoreboard.html
fi
# Generate preliminary puzzles list
2012-07-22 17:14:06 -06:00
if [ ! -f $WWW/puzzles.html ]; then
./mkpage puzzles.cgi > $WWW/puzzles.html
fi
# Run pointsd every time a new points file is dropped
if [ -x /sbin/inotifyd ]; then
exec /sbin/inotifyd ./pointsd $NEWDIR:y
fi
# Simulate inotifyd by polling
while true; do
2012-07-16 17:46:27 -06:00
find $NEWDIR -type f | while read fn; do
./pointsd m $NEWDIR ${fn##*/}
done
sleep 7
done