Make an actually working server, hopefully

This commit is contained in:
Neale Pickett 2017-02-05 16:42:41 -07:00
parent dfb6f54d78
commit 1f2132d41b
82 changed files with 148 additions and 20 deletions

View File

@ -50,19 +50,56 @@ Running A Production Server
XXX: Update this XXX: Update this
How to set it up How to install it
-------------------- --------------------
It's made to be virtualized, It's made to be virtualized,
so you can run multiple contests at once if you want. so you can run multiple contests at once if you want.
If you were to want to run it out of `/opt/koth`, If you were to want to run it out of `/srv/moth`,
do the following: do the following:
$ mkdir -p /opt/koth/mycontest $ mothinst=/srv/moth/mycontest
$ ./install /opt/koth/mycontest $ mkdir -p $mothinst
$ cp kothd /opt/koth $ install.sh $mothinst
Yay, you've got it set up. Yay, you've got it installed.
How to run a contest
------------------------
`mothd` runs through every contest on your server every few seconds,
and does housekeeping tasks that make the contest "run".
If you stop `mothd`, people can still play the contest,
but their points won't show up on the scoreboard.
A handy side-effect here is that if you need to meddle with the points log,
you can just kill `mothd`,
do you work,
then bring `mothd` back up.
$ cp src/mothd /srv/moth
$ /srv/moth/mothd
You're also going to need a web server if you want people to be able to play.
How to run a web server
-----------------------------
Your web server needs to serve up files for you contest out of
`$mothinst/www`.
If you don't want to fuss around with setting up a full-featured web server,
you can use `tcpserver` and `eris`,
which is what we use to run our contests.
`tcpserver` is part of the `uscpi-tcp` package in Ubuntu.
You can also use busybox's `tcpsvd` (my preference, but a PITA on Ubuntu).
`eris` can be obtained at https://woozle.org/neale/g.cgi/net/eris/about/
$ mothinst=/srv/moth/mycontest
$ $mothinst/bin/httpd
Installing Puzzle Categories Installing Puzzle Categories
@ -71,16 +108,7 @@ Installing Puzzle Categories
Puzzle categories are distributed in a different way than the server. Puzzle categories are distributed in a different way than the server.
After setting up (see above), just run After setting up (see above), just run
$ /opt/koth/mycontest/bin/install-category /path/to/my/category $ /srv/koth/mycontest/bin/install-category /path/to/my/category
Running It
-------------
Get your web server to serve up files from
`/opt/koth/mycontest/www`.
Then run `/opt/koth/kothd`.
Permissions Permissions

16
bin/httpd Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh -e
# Starts a standalone server using tcpsvd and eris
echo "Figuring out web user..."
for www in www-data http tc _ _www; do
id $www && break
done
if [ $www = _ ]; then
echo "Unable to determine httpd user on this system. Dying."
exit 1
fi
cd $(dirname $0)/../www
tcpserver -RHI localhost -u $www -g $www 0 80 eris -c -.

View File

@ -7,6 +7,8 @@ else
fi fi
basedir=$(pwd) basedir=$(pwd)
printf "Updating moth instance in %s\n" $(pwd)
# Do nothing if `disabled` is present # Do nothing if `disabled` is present
if [ -f disabled ]; then if [ -f disabled ]; then
exit exit

View File

@ -36,7 +36,7 @@ def page(title, body):
<html> <html>
<head> <head>
<title>{title}</title> <title>{title}</title>
<link rel="stylesheet" href="/files/src/www/res/style.css"> <link rel="stylesheet" href="/files/www/res/style.css">
</head> </head>
<body> <body>
<h1>{title}</h1> <h1>{title}</h1>

View File

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View File

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

View File

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

View File

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

View File

Before

Width:  |  Height:  |  Size: 107 KiB

After

Width:  |  Height:  |  Size: 107 KiB

View File

Before

Width:  |  Height:  |  Size: 129 KiB

After

Width:  |  Height:  |  Size: 129 KiB

View File

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View File

Before

Width:  |  Height:  |  Size: 144 B

After

Width:  |  Height:  |  Size: 144 B

View File

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 64 KiB

View File

Before

Width:  |  Height:  |  Size: 197 KiB

After

Width:  |  Height:  |  Size: 197 KiB

75
www/index.html Normal file
View File

@ -0,0 +1,75 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>Welcome</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<h1><img src="images/tf6.png" alt="Cyber FIRE"></h1>
<nav>
<ul>
<li><a href="register.html">Register</a></li>
<li><a href="puzzles.html">Puzzles</a></li>
<li><a href="scoreboard.html">Scoreboard</a></li>
</ul>
</nav>
<section>
<h2>Getting Started</h2>
<p>
Here is what you need to do:
</p>
<ol>
<li>
<a href="register.html">Register</a> your team.
This only needs to happen once per team,
so if somebody else on your team has already done it,
you don't need to.
</li>
<li>
Get an <a href="puzzles.html">overview of puzzles</a>,
and start working on something.
The list of open puzzles changes over time,
you need to reload the page to get the current version!
</li>
<li>
Check the <a href="scoreboard.html">scoreboard</a>
in another tab,
to see how your team is doing.
</li>
</ol>
</section>
<section>
<h2>Reading Material</h2>
<p>
Stuck? Taking a break?
Here are some things to read.
</p>
<ul>
<li><a href="credits.html">Credits</a></li>
<li>
<a href="scoring.html">About Scoring</a>
explains how we calculate scores,
and why.
Reading this will help you formulate a strategy to win.
</li>
</ul>
</section>
<section id="sponsors">
<img src="images/lanl.png" alt="Los Alamos National Laboratory">
<img src="images/doe.png" alt="US Department Of Energy">
<img src="images/sandia.png" alt="Sandia National Laboratories">
</section>
</body>
</html>

View File

@ -4,7 +4,13 @@
<title>Open Puzzles</title> <title>Open Puzzles</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css" type="text/css"> <link rel="stylesheet" href="style.css" type="text/css">
<script src="puzzles.js" onload="init()" async></script> <link rel="stylesheet" href="res/style.css">
<link rel="icon" href="res/luna-moth.svg" type="image/svg+xml">
<link rel="icon" href="res/luna-moth.png" type="image/png">
<script src="res/common.js"></script>
<script src="res/terminal.js"></script>
<script src="res/puzzles.js"></script>
</head> </head>
<body> <body>
<h1>Open Puzzles</h1> <h1>Open Puzzles</h1>

View File

Before

Width:  |  Height:  |  Size: 236 KiB

After

Width:  |  Height:  |  Size: 236 KiB

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

View File

@ -31,11 +31,12 @@ function puzzlesRefresh(term, obj) {
if (points == 0) { if (points == 0) {
i.textContent = "‡"; i.textContent = "‡";
} else { } else {
var a = createElement('span'); var a = createElement('a');
i.appendChild(a); i.appendChild(a);
a.className = "link"; a.className = "link";
a.textContent = points; a.textContent = points;
a.addEventListener("click", loadPuzzle.bind(undefined, cat, id, points)); a.href = cat + "/" + id + "/index.html";
// a.addEventListener("click", loadPuzzle.bind(undefined, cat, id, points));
} }
} }