# Push-triggered stagit publication

`setup-stagit-pages.sh` is the publisher; the copy under a repository's `raw/`
web path is output, not the installed executable. Install the reviewed script
as root at `/usr/local/libexec/setup-stagit-pages.sh` (mode 755, not git-writable).

The common Gitolite post-receive hook queues a rebuild by touching
`/var/lib/stagit/pending` only for repositories with `gitolite.stagit=true`.
Configure that flag only on public repository groups in gitolite-admin.
The hook does not execute pushed scripts, run sudo, or wait for page generation.
Existing mirroring and MinCI remain independent.

Install the `.path` and `.service` files in `/etc/systemd/system/`. Create
`/var/lib/stagit` owned by git, and grant git write access to the static docroot
and generated public repo directories. Do not grant git write access to the
publisher, systemd units, or environment configuration.

Site settings go in `/etc/default/stagit-publish` (root-owned):

```ini
STAGIT_SITE_NAME=git.nply.org
STAGIT_CLONE_PREFIX=https://git.nply.org/
STAGIT_SITE_LOGO=/logo.png
STAGIT_SCRIPT=/enhancements.js
```

Enable with `systemctl enable --now stagit-publish.path`.

- Full rebuild: `touch /var/lib/stagit/pending` as git, or start the service.
- Logs: `journalctl -u stagit-publish.service`.
- Disable automatic builds: `systemctl disable --now stagit-publish.path`.
- Test: `STAGIT_TEST_HOOK=/path/to/post-receive python3 check-stagit-publish.py`.

The service runs as git with a filesystem sandbox. It clears the pending marker
before building, so pushes during generation leave another marker for the next
run. `flock` serializes builds. Multiple pushes are coalesced into a full rebuild
of enabled repos; use per-repo queuing only if build duration becomes a problem.
The index is replaced atomically; repo HTML is copied after each generation.
This is not an atomic whole-site deployment. Failures are visible in the journal;
a new push or manual queue retries them.

The generator never changes repository HEADs or pulls worktrees. It preserves
existing CSS/logo files. It does not remove previously published paths when
files are deleted or a repo is made private: revocation requires removing that
repo's public output explicitly. Disabling its flag prevents future publication
but is not a privacy cleanup mechanism.
