diff --git a/bin/kothd b/bin/kothd deleted file mode 100755 index 6f2128f..0000000 --- a/bin/kothd +++ /dev/null @@ -1,58 +0,0 @@ -#! /bin/sh - -echo "Figuring out web user..." -for www in www-data http _; do - id $www && break -done - -if [ $www = _ ]; then - echo "Unable to determine httpd user on this system. Dying." - exit 1 -fi - -initialize () { - for i in points.new points.tmp teams; do - mkdir -p state/$i - setfacl -m ${www}:rwx state/$i - done - - >> state/points.log - hd < /dev/urandom | awk '{print $3 $4 $5 $6;}' | head -n 100 > state/teams/assigned.txt -} - -once () { - if [ -f disabled ]; then - return - fi - - if ! [ -d state ]; then - initialize $1 - fi - - # Collect new points - find state/points.new -type f | while read fn; do - cat $fn >> state/points.log - rm $fn - done - - # Generate new puzzles.html - if $KOTH_BASE/puzzles.cgi > www/puzzles.new; then - mv www/puzzles.new www/puzzles.html - fi - - # Generate new points.json - if $KOTH_BASE/points > www/points.new; then - mv www/points.new www/points.json - fi -} - -cd $(basename $0) -KOTH_BASE=$(pwd) - -while true; do - for dn in $KOTH_BASE/*; do - cd $dn - once - done - sleep 5 -done diff --git a/bin/new b/bin/new new file mode 100755 index 0000000..e765e88 --- /dev/null +++ b/bin/new @@ -0,0 +1,37 @@ +#! /bin/sh + +newdir=$1 +if [ -z "$newdir" ]; then + echo "Usage: $0 NEWDIR" + exit 1 +fi + +KOTH_BASE=$(cd $(dirname $0)/.. && pwd) + +echo "Figuring out web user..." +for www in www-data http _; do + id $www && break +done + +if [ $www = _ ]; then + echo "Unable to determine httpd user on this system. Dying." + exit 1 +fi + +mkdir -p $newdir +cd $newdir + +for i in points.new points.tmp teams; do + mkdir -p state/$i + setfacl -m ${www}:rwx state/$i +done + +>> state/points.log + +if ! [ -f assigned.txt ]; then + hd < /dev/urandom | awk '{print $3 $4 $5 $6;}' | head -n 100 > assigned.txt +fi + +mkdir -p www +cp -r $KOTH_BASE/html/* www/ +cp $KOTH_BASE/bin/*.cgi www/ diff --git a/bin/once b/bin/once new file mode 100755 index 0000000..87dfdc2 --- /dev/null +++ b/bin/once @@ -0,0 +1,30 @@ +#! /bin/sh + +cd $(dirname $0) + +# Do nothing if `disabled` is present +if [ -f disabled ]; then + exit +fi + +# Reset to initial state if `reset` is present +if [ -f reset ]; then + rm -f state/teams/* state/points.new/* state/points.tmp/* + > state/points.log +fi + +# Collect new points +find state/points.new -type f | while read fn; do + cat $fn >> state/points.log + rm $fn +done + +# Generate new puzzles.html +if $KOTH_BASE/puzzles.cgi > www/puzzles.new; then + mv www/puzzles.new www/puzzles.html +fi + +# Generate new points.json +if $KOTH_BASE/points > www/points.new; then + mv www/points.new www/points.json +fi diff --git a/html/register.cgi b/bin/register.cgi similarity index 95% rename from html/register.cgi rename to bin/register.cgi index c05f8fc..23ad37f 100755 --- a/html/register.cgi +++ b/bin/register.cgi @@ -40,7 +40,7 @@ EOF if [ -z "$hash" ] || [ -z "$team" ]; then echo "
Empty field, cannot complete request
" -elif ! grep -q "^$hash$" state/teams/assigned.txt; then +elif ! grep -q "^$hash$" assigned.txt; then echo "That hash has not been assigned.
" elif [ -f state/teams/names/$hash ]; then echo "That hash has already been registered.
" diff --git a/html/credits.html b/html/credits.html index 82481a4..d0c8756 100644 --- a/html/credits.html +++ b/html/credits.html @@ -8,7 +8,7 @@Dirtbags King of the Hill was created by:
+Parts of this contest were inspired by contests from:
+- Lastly, this contest would not exist were it not for hundreds of - thousands of lines of code from free software authors around the - world, including: + This contest would not exist were it not for hundreds of + thousands of lines of code from free software authors around the + world, including:
- Stuck? Need a break? In the bathroom? + Stuck? Taking a break? Here are some things to read.
@@ -57,12 +65,5 @@