mirror of https://github.com/dirtbags/moth.git
45 lines
927 B
Plaintext
45 lines
927 B
Plaintext
|
#! /bin/sh -e
|
||
|
|
||
|
exec 2>&1
|
||
|
|
||
|
install -d /var/lib/ctf
|
||
|
|
||
|
# Create CTF and nobody users
|
||
|
touch /etc/group /etc/passwd
|
||
|
addgroup -g 65534 nogroup || true
|
||
|
adduser -D -S -h /var/lib/ctf -H ctf || true
|
||
|
adduser -D -g nogroup -u 65534 -h /tmp -H nobody || true
|
||
|
|
||
|
# Set up base directories
|
||
|
NEWDIR=/var/lib/ctf/points.new
|
||
|
install -d /var/www
|
||
|
install -d /var/lib/ctf
|
||
|
install -o ctf -m 0755 -d $NEWDIR
|
||
|
install -o ctf -m 0755 -d /var/lib/ctf/points.tmp
|
||
|
|
||
|
# Create some files
|
||
|
CLAIM=/var/lib/ctf/claim.db
|
||
|
touch $CLAIM
|
||
|
chown ctf $CLAIM
|
||
|
touch /var/lib/ctf/points.log
|
||
|
|
||
|
# 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
|
||
|
|
||
|
# Simulate inotifyd
|
||
|
cd $NEWDIR
|
||
|
while true; do
|
||
|
for fn in *; do
|
||
|
[ -f "$fn" ] || continue
|
||
|
./pointsd m $NEWDIR $fn
|
||
|
done
|
||
|
sleep 7
|
||
|
done
|