And with that, I think it is working again

This commit is contained in:
Neale Pickett 2015-04-12 11:11:15 -06:00
parent d4e4a10a98
commit 40233fe0c8
7 changed files with 126 additions and 4787 deletions

View File

@ -67,13 +67,14 @@ EOF
} }
cat=$(basename $indir) cat=$(basename $indir)
outdir=$(dirname $0)/puzzles/$cat outdir=$(dirname $0)/../packages/$cat
uanswers=$outdir/answers.unsorted uanswers=$outdir/answers.unsorted
usummary=$outdir/summary.unsorted usummary=$outdir/summary.unsorted
umap=$outdir/map.unsorted umap=$outdir/map.unsorted
mkdir -p $outdir
if ! [ -r $outdir/mkpuzzles.salt ]; then if ! [ -r $outdir/mkpuzzles.salt ]; then
dd if=/dev/urandom bs=1 count=16 2>/dev/null | md5sum | cut -d\ -f1 > $outdir/salt dd if=/dev/urandom bs=1 count=16 2>/dev/null | md5sum | cut -c1-16 > $outdir/salt
fi fi
read salt < $outdir/salt read salt < $outdir/salt
@ -161,7 +162,17 @@ for dn in $indir/[0-9]*; do
printf "%d %s\n" $points $odn >> $umap printf "%d %s\n" $points $odn >> $umap
done done
echo "Generating URL map"
sort -n $umap > $outdir/map.txt sort -n $umap > $outdir/map.txt
echo "Generating answers list"
sort -n $uanswers > $outdir/answers.txt sort -n $uanswers > $outdir/answers.txt
echo "Generating summary"
[ -f $usummary ] && sort -ns $usummary > $outdir/summary.txt [ -f $usummary ] && sort -ns $usummary > $outdir/summary.txt
echo "Linking into web space"
ln -s ../packages/$cat/puzzles www/$cat
echo "Cleaning up"
rm -f $uanswers $usummary $umap rm -f $uanswers $usummary $umap

View File

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
cd $(dirname $0) cd $(dirname $0)/..
# Do nothing if `disabled` is present # Do nothing if `disabled` is present
if [ -f disabled ]; then if [ -f disabled ]; then
@ -10,7 +10,7 @@ fi
# Reset to initial state if `reset` is present # Reset to initial state if `reset` is present
if [ -f reset ]; then if [ -f reset ]; then
rm -f state/teams/* state/points.new/* state/points.tmp/* rm -f state/teams/* state/points.new/* state/points.tmp/*
> state/points.log : > state/points.log
fi fi
# Collect new points # Collect new points
@ -20,11 +20,11 @@ find state/points.new -type f | while read fn; do
done done
# Generate new puzzles.html # Generate new puzzles.html
if $KOTH_BASE/puzzles.cgi > www/puzzles.new; then if www/puzzles.cgi > www/puzzles.new; then
mv www/puzzles.new www/puzzles.html mv www/puzzles.new www/puzzles.html
fi fi
# Generate new points.json # Generate new points.json
if $KOTH_BASE/points > www/points.new; then if bin/points state/points.log > www/points.new; then
mv www/points.new www/points.json mv www/points.new www/points.json
fi fi

View File

@ -108,7 +108,7 @@ hr {
/**** Section ****/ /**** Section ****/
section, nav { section, nav, address {
color: #35170c; color: #35170c;
max-width: 35em; max-width: 35em;
border-radius: 0.6em; border-radius: 0.6em;
@ -116,7 +116,7 @@ section, nav {
padding: 0.5em; padding: 0.5em;
} }
section { section, address {
background: #e1caa5; background: #e1caa5;
} }

View File

@ -54,6 +54,10 @@ function scoreboard(element) {
for (var i in teams) { for (var i in teams) {
winners.push(teams[i]); winners.push(teams[i]);
} }
if (winners.length == 0) {
// No teams!
return;
}
winners.sort(teamCompare); winners.sort(teamCompare);
winners.reverse(); winners.reverse();

File diff suppressed because it is too large Load Diff

View File

@ -48,7 +48,7 @@ web () {
cgi () { cgi () {
target=$DESTDIR/www/$(basename $1 .c) target=$DESTDIR/www/$(basename $1 .c)
if older $target $@; then if older $target src/common.c $@; then
mkdir -p $(dirname $target) mkdir -p $(dirname $target)
src=$1; shift src=$1; shift
echo "CGI $src" echo "CGI $src"
@ -64,6 +64,7 @@ setup() {
mkdir -p $dir mkdir -p $dir
setfacl -m ${www}:rwx $dir setfacl -m ${www}:rwx $dir
done done
mkdir -p $DESTDIR/packages
>> $DESTDIR/state/points.log >> $DESTDIR/state/points.log
if ! [ -f $DESTDIR/assigned.txt ]; then if ! [ -f $DESTDIR/assigned.txt ]; then
hd </dev/urandom | awk '{print $3 $4 $5 $6;}' | head -n 100 > $DESTDIR/assigned.txt hd </dev/urandom | awk '{print $3 $4 $5 $6;}' | head -n 100 > $DESTDIR/assigned.txt
@ -97,6 +98,8 @@ git ls-files | while read fn; do
;; ;;
src/common.c) src/common.c)
;; ;;
src/*.h)
;;
src/pointscli.c) src/pointscli.c)
cc $fn src/common.c cc $fn src/common.c
;; ;;
@ -106,8 +109,6 @@ git ls-files | while read fn; do
src/*.c) src/*.c)
cc $fn cc $fn
;; ;;
src/*.h)
;;
*) *)
echo "??? $fn" echo "??? $fn"
;; ;;

View File

@ -203,9 +203,9 @@ cgi_foot()
{ {
printf("\n</section>\n"); printf("\n</section>\n");
printf("<nav><ul>\n"); printf("<nav><ul>\n");
printf("<li><a href="register.html">Register</a></li>\n"); printf("<li><a href=\"register.html\">Register</a></li>\n");
printf("<li><a href="puzzles.html">Puzzles</a></li>\n"); printf("<li><a href=\"puzzles.html\">Puzzles</a></li>\n");
printf("<li><a href="scoreboard.html">Scoreboard</a></li>\n"); printf("<li><a href=\"scoreboard.html\">Scoreboard</a></li>\n");
printf("</ul></nav>\n"); printf("</ul></nav>\n");
printf("</body></html>\n"); printf("</body></html>\n");
@ -393,12 +393,12 @@ ctf_chdir()
} }
/* /*
* Keep going up one directory until there's a packages directory * Keep going up one directory until there's an assigned.txt file
*/ */
for (i = 0; i < 5; i += 1) { for (i = 0; i < 5; i += 1) {
struct stat st; struct stat st;
if ((0 == stat("packages", &st)) && S_ISDIR(st.st_mode)) { if ((0 == stat("assigned.txt", &st)) && S_ISREG(st.st_mode)) {
return; return;
} }
chdir(".."); chdir("..");
@ -473,7 +473,7 @@ team_exists(char const *teamhash)
/* /*
* stat seems to be the preferred way to check for existence. * stat seems to be the preferred way to check for existence.
*/ */
ret = stat(state_path("teams/names/%s", teamhash), &buf); ret = stat(state_path("teams/%s", teamhash), &buf);
if (-1 == ret) { if (-1 == ret) {
return 0; return 0;
} }