mirror of https://github.com/dirtbags/moth.git
Move assigned.txt into state
This commit is contained in:
parent
cbe671dbc2
commit
9b94c2b1f0
|
@ -2,14 +2,11 @@ FROM neale/eris
|
|||
|
||||
RUN apk --no-cache add lua5.2
|
||||
RUN apk --no-cache add lua5.3
|
||||
RUN ln -s lua5.2 /usr/bin/lua
|
||||
|
||||
# Install MOTH. This could be less obtuse.
|
||||
COPY www /moth/www
|
||||
COPY bin /moth/bin
|
||||
RUN mkdir -p /moth/state/teams /moth/state/points.new /moth/state/points.tmp
|
||||
RUN chown www:www /moth/state/teams /moth/state/points.new /moth/state/points.tmp
|
||||
RUN mkdir -p /moth/packages
|
||||
RUN touch /moth/state/points.log
|
||||
RUN ln -s ../state/puzzles.json /moth/www/puzzles.json
|
||||
RUN ln -s ../state/points.json /moth/www/points.json
|
||||
|
||||
|
|
25
bin/once
25
bin/once
|
@ -13,16 +13,19 @@ log () {
|
|||
|
||||
# Do nothing if `disabled` is present
|
||||
if [ -f disabled ]; then
|
||||
log "Instance disabled: doing nothing"
|
||||
log "Instance disabled; doing nothing"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Reset to initial state if `reset` is present
|
||||
if [ -f reset ]; then
|
||||
log "Resetting state"
|
||||
rm -f state/teams/* state/points.new/* state/points.tmp/*
|
||||
# Reset to initial state?
|
||||
if [ ! -f state/initialized ]; then
|
||||
log "Resetting contest state"
|
||||
|
||||
rm -rf state/teams state/points.new state/points.tmp
|
||||
mkdir -p state/teams state/points.new state/points.tmp
|
||||
chown www:www state/teams state/points.new state/points.tmp # Needs root. Use Docker.
|
||||
: > state/points.log
|
||||
rm -f reset
|
||||
echo 'Remove this file to obliterate teams and points' > state/initialized
|
||||
fi
|
||||
|
||||
# Create some team names if needed
|
||||
|
@ -31,6 +34,16 @@ if [ ! -f state/assigned.txt ]; then
|
|||
hd </dev/urandom | awk '{print $3 $4 $5 $6;}' | head -n 100 > state/assigned.txt
|
||||
fi
|
||||
|
||||
# Install new categories
|
||||
for pkg in puzzles/*; do
|
||||
cat=$(basename $pkg .zip)
|
||||
if [ ! -f packages/$cat/installed ] || [ $pkg -nt packages/$cat/installed ]; then
|
||||
log "Installing $pkg"
|
||||
bin/install-category $pkg
|
||||
: >packages/$cat/installed
|
||||
fi
|
||||
done
|
||||
|
||||
# Helpful error message
|
||||
if [ $(ls packages | wc -l) -eq 0 ]; then
|
||||
log "error: No packages installed"
|
||||
|
|
|
@ -85,7 +85,7 @@ There are five entries in each instance directory, described in detail below:
|
|||
|
||||
|
||||
|
||||
`assigned.txt`
|
||||
`state/assigned.txt`
|
||||
----------------
|
||||
|
||||
This is just a list of tokens that have been assigned.
|
||||
|
|
|
@ -98,7 +98,7 @@ end
|
|||
|
||||
-- Traverse up to find assigned.txt
|
||||
for i = 0, 5 do
|
||||
local f = io.open(koth.path("assigned.txt"))
|
||||
local f = io.open(koth.path("state/assigned.txt"))
|
||||
if (f) then
|
||||
f:close()
|
||||
break
|
||||
|
|
|
@ -13,7 +13,7 @@ hash = hash:match("[0-9a-f]*")
|
|||
|
||||
if ((hash == "") or (team == "")) then
|
||||
koth.page("Invalid Entry", "Oops! Are you sure you got that right?")
|
||||
elseif (not koth.anchored_search(koth.path("assigned.txt"), hash)) then
|
||||
elseif (not koth.anchored_search(koth.path("state/assigned.txt"), hash)) then
|
||||
koth.page("Invalid Hash", "Oops! I don't have a record of that hash. Did you maybe use capital letters accidentally?")
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue