ikiwiki hosting internals/ design

Each site has a hostname, which is a subdomain of one of our domains. For example, foo.branchable.com.

Each site has an owner, which is an openid or email. Typically the admin is set to the same value as the owner, but a site may have other admins who do not own it, and it's also possible for its owner not to be an admin at all.

A site may also have one or more aliases; domain names that CNAME to its hostname.

The primary url of a site uses either its hostname, or one of its aliases. Ikiwiki is configured to use this in its url and cgiurl.

From the hostname, a unique username is derived. Ikiwiki runs as that user, and data files associated with the site are stored in the user's home directory.

Outside the home directory, runtime files for the site are managed in `/var/www/`, `/var/log/ikiwiki-hosting/`, and apacheconfig.

The home directory has these contents:

- `public_html` - the site's html is here (but its cgis are created in /var/www so suidexec can be used)
- `source.git` - bare git repo (or similar for other VCS)
- `source` - checkout of the wiki's source
- `ikiwiki.setup` - config file for the site
- `apache` - directory contains optional apache configs ssl certs, etc)
- `tmp` - per-user temp directory

The home directory itself is a checkout of a different branch of the VCS repository, the "setup" branch. Into that branch are checked the `ikiwiki.setup` file and other configuration and state files. (But not ssh keys, htpassword files, etc.) Remote users may not directly commit to that branch.

The ikisite program handles creating, deleting, and other administration of these sites.

A backupformat encapsulates the above into a single file for backups and transfer.

A customersite holds information about customers.

## locking

ikisite needs to lock sites as it is creating, deleting, or modifying them, to prevent concurrency issues. This is done using a directory in `/var`, the `lockdir`. The lock files in the lockdir correspond to each site's username.