2011-10-13 17:22:03 -06:00
|
|
|
#! /bin/sh -e
|
2010-09-24 17:24:43 -06:00
|
|
|
|
|
|
|
exec 2>&1
|
2010-09-29 17:38:54 -06:00
|
|
|
|
2011-10-13 17:22:03 -06:00
|
|
|
install -d /var/lib/ctf
|
|
|
|
|
2011-10-13 22:12:53 -06:00
|
|
|
# Create CTF and nobody users
|
2011-10-13 17:22:03 -06:00
|
|
|
touch /etc/group /etc/passwd
|
2011-10-13 22:12:53 -06:00
|
|
|
addgroup -g 65534 nogroup || true
|
2011-10-13 17:22:03 -06:00
|
|
|
adduser -D -S -h /var/lib/ctf -H ctf || true
|
2011-10-13 22:12:53 -06:00
|
|
|
adduser -D -g nogroup -u 65534 -h /tmp -H nobody || true
|
2011-10-13 17:22:03 -06:00
|
|
|
|
2011-10-13 21:15:11 -06:00
|
|
|
# Set up base directories
|
2011-10-13 17:22:03 -06:00
|
|
|
NEWDIR=/var/lib/ctf/points.new
|
|
|
|
install -d /var/www
|
2011-10-13 21:15:11 -06:00
|
|
|
install -d /var/lib/ctf
|
2011-10-13 17:22:03 -06:00
|
|
|
install -o ctf -m 0755 -d $NEWDIR
|
2010-09-29 17:38:54 -06:00
|
|
|
install -o ctf -m 0755 -d /var/lib/ctf/points.tmp
|
2011-10-13 21:15:11 -06:00
|
|
|
|
|
|
|
# Make tokens database now, this is as good a time as any
|
|
|
|
TOKENS=/var/lib/ctf/tokens.db
|
|
|
|
for fn in $TOKENS /opt/*/tokens.txt; do
|
|
|
|
[ -f "$fn" ] || continue
|
|
|
|
cat $fn
|
|
|
|
done | sort | uniq > $TOKENS.new
|
|
|
|
mv $TOKENS.new $TOKENS
|
|
|
|
|
|
|
|
# Create some files
|
|
|
|
CLAIM=/var/lib/ctf/claim.db
|
|
|
|
touch $CLAIM
|
|
|
|
chown ctf $CLAIM
|
2010-10-22 09:36:28 -06:00
|
|
|
touch /var/lib/ctf/points.log
|
|
|
|
|
2011-10-13 17:22:03 -06:00
|
|
|
# Generate preliminary scoreboard
|
|
|
|
if ! [ -f /var/www/scoreboard.html ]; then
|
|
|
|
/opt/mcp/bin/scoreboard < /dev/null > /var/www/scoreboard.html
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ -x /sbin/inotifyd ]; then
|
|
|
|
exec /sbin/inotifyd ./pointsd $NEWDIR:y
|
|
|
|
fi
|
2010-10-29 00:07:03 -06:00
|
|
|
|
2011-10-13 17:22:03 -06:00
|
|
|
# Simulate inotifyd
|
|
|
|
cd $NEWDIR
|
|
|
|
while true; do
|
|
|
|
for fn in *; do
|
|
|
|
[ -f "$fn" ] || continue
|
|
|
|
./pointsd m $NEWDIR $fn
|
|
|
|
done
|
|
|
|
sleep 7
|
|
|
|
done
|