Nokotan -- not very complicated Spartan daemon.

TL;DR
Run the following as root:

make install
nokotan -u nobody

And put your files to /var/spartan/ (make sure they are readable by
``nobody'' user).

Put index.gmi to a directory if you want it to be displayed in a certain
way. Otherwise the directory contents will be displayed. You can add a
.message file which will be displayed before the contents.



Supported command line parameters:
-d <absolute-path>
	A directory to serve. Default is /var/spartan/
-p <port>
	A port to listen on. Default is 300
-u <user name>
	The user to which privilleges are dropped.
	Default - do not switch user and group.
-f
	Do not daemonize. Work in foreground, writing log to stderr.
-v
	Be more verbose.
	Use once to enable logging of requests.
	Use twice to enable debug messages (recommended with -f).
-t <path>
	Load additional media types database. Can be used
	multiple times. (See below)
-F
	Enable a footer after directory listings.
	Footer is a single short line ``Generated and served
	by Nokotan''.
-V
	Enable virtual hosts support (see below).
-h
	Write this list of options and the program version.

## Directories

When a directory is requested, Nokotan first looks for an ``index.gmi''
file in this directory. If such file exists, then Nokotan just sends it.

If index.gmi does not exist, then Nokotan generates a directory listing. If
a requested directory contains a file named .message, this file is written
before the listing, much like in many FTP daemons.

Directory listing items are sorted in this manner: all directories are put
before other files, and everything is sorted alphabetically, ignoring case.

## MIME types

Nokotan tries to read a database file from /etc/nokotan-types. Additional
databases can be supplied with -t parameter. They have precedence over the
system-wide one. When /etc/nokotan-types does not exist, and no additional
files were supplied, it uses small hard-coded set of types from older
versions.

When Nokotan recieves SIGHUP, then it reloads type databases (even supplied
with -t).

### Types database file format
Empty and commented (starting with #) lines are ignored.

[type1]
patt1
patt2

[type2]
patt3
...

'patt's are common Unix glob(7) patterns (except that . and / don't have
special behavior). Slash at the beginning of a pattern is optional, but
useful if a pattern starts with [.

Nokotan finds the first pattern to which a requested path matches, and uses
a MIME type from its section. If no such pattern found, it uses hard-coded
types, so, for simple ASCII-only sites creating such database is
unnecessary.

### Example file
[text/gemini; charset=KOI8-R]
/ru/*.gmi
/ru/*.message

[text/gemini; charset=US-ASCII]
*.gmi
*.message

[text/plain]
/*.txt

[audio/ogg]
music/*

### Fallback MIME-types
"text/gemini" is for .gmi, .gem, .gemini and .message files;
"text/plain" is used by .txt, .sh, .c and files with no suffix
"video/mp4" for .mp4
"audio/mpeg" for .mp3
"application/octet-stream" for other suffixes;

Fallback charset parameter is US-ASCII.

## Virtual hosts

With -V flag, Nokotan treats each subdirectory of a Spartan root as a
separate vitrual host's root. Subdirectories names are case-insensitive
domain names of virtual hosts they are served by.

The directory ``default'' (if it exists) will be used, if a requested host
does not match any other root.




If you experience troubles with Nokotan daemon (and the real Nokotan too!),
write me to <arbo@sh.pp.ru>
