repository

BlowfishCMS

A small content management system for OpenBSD

version 0.45.6 · ISC · 2026-12-03 · releases

420 lines · 21.7 KB · view it drawn · download this file

# Keeping a BlowfishCMS site running

Everything on the server goes through one command, `blowfishctl`, run with
`doas`. `man blowfishctl` describes every command; `doas blowfishctl help`
lists them.

## At a glance

| Command | Does |
|---|---|
| `status` | Services, certificate expiry, free disk space, release, and whether the mail token and password are set. |
| `update [--check] [--skip-tests] FILE.tar.gz` | Installs a new release safely (below). |
| `rollback` | Puts back the code from before the last update. |
| `releases` | Lists the live release and the kept ones. |
| `restart` | Restarts the site's services. |
| `backup [--with-secrets]` | Writes a backup archive. |
| `password [NAME]` | Sets an admin user's password and ends their sessions. A NAME that isn't a user yet becomes an owner (a way back in). Without NAME: the install's admin account. |
| `unlock` | Clears failed sign-ins after a lockout. |
| `mfa-off NAME` | Turns off two-step sign-in for a user who has lost their phone and recovery codes. |
| `nightly` | The nightly backup. Runs from cron; see [Backups](#backups). |
| `places` | Fetches the city database Analytics looks visitors' places up in (below). The nightly job does it once a month. |
| `requests` | Carries out what owners asked for on the System screen. Runs from cron every minute. |
| `mail-token` | Sets the Postmark token from the terminal (the Mail screen does the same). |
| `certificate` | Gets or renews the HTTPS certificate. Runs daily from cron. |
| `httpd` | Rewrites httpd's configuration for the site. Updates do this. |
| `migrate` | Brings the catalogue's tables up to date. Updates do this. |
| `addon list / enable / disable / install / remove` | Add-ons (below). |
| `files` | Serves the site's own files from `/opt/blowfishcms-files` (below). |

## Where everything lives

| What | Where | Owner |
|---|---|---|
| Code (the live release) | `/opt/blowfishcms` | root |
| Public files (CSS, JS and SVG with compressed `.gz` copies) | `/var/www/htdocs/blowfishcms` | root |
| Site settings file | `/var/www/etc/blowfishcms.conf` | root |
| Catalogue: pages, uploads, articles, themes, settings | `/var/www/var/db/blowfishcms/catalog.sqlite` | `_bfadmin` |
| Media | `/var/www/media/blowfishcms`, served at `/media/` | `_bfadmin` |
| The picture library (its folders are these directories) | `/var/www/media/blowfishcms/pictures/` | `_bfadmin` |
| Comments and likes | `/var/www/var/db/blowfishcms-comments` | `_bfcomments` |
| Analytics (visitor numbers; "off" is the file `analytics-off` beside it) | `/var/www/var/db/blowfishcms-comments/analytics/`, mode 0700 | `_bfcomments` |
| Analytics' city database (`places.mmdb`, DB-IP's IP to City Lite; `places.month` says which month) | the same folder, mode 0600 | `_bfcomments` |
| Contact form log, rate limits, mail settings | `/var/www/var/db/blowfishcms-contact` | `_bfcontact` |
| Postmark token | `/var/www/etc/blowfishcms/postmark.token` | `_bfcontact`, mode 0400 |
| Admin users (names, roles, sessions; every service with admin screens reads them) | the catalogue's `admin_users` table | `_bfadmin` |
| Admin users' bcrypt passwords and email addresses (admin service only; in backups) | `/var/www/var/db/blowfishcms/admin/accounts.sqlite` | `_bfadmin`, mode 0600 |
| Admin session key | `/var/www/etc/blowfishcms-session/session.key` | `_bfadmin`:`_bfstaff`, mode 0640 |
| Failed sign-ins (last hour) | `/var/www/var/db/blowfishcms/admin/logins.json` | `_bfadmin` |
| Two-step sign-in keys (one file per user, not in backups) | `/var/www/var/db/blowfishcms/admin/mfa/` | `_bfadmin`, mode 0600 |
| The System screen's requests, uploads, results and backup downloads | `/var/www/var/db/blowfishcms/system/` | `_bfadmin` writes `requests/` and `releases/`; root writes the rest |
| Add-on data / add-on secrets | `/var/www/var/db/blowfishcms-addons/NAME`, `/var/www/etc/blowfishcms-addons/NAME` | the add-on's account |
| Files an add-on serves (Live's stream pieces; httpd serves them at `/x/NAME/files/`) | `/var/www/var/db/blowfishcms-addons/NAME-files` | the add-on's account, group `www`, mode 0750 |
| Live's stream being recorded (`rec/`) and saved streams waiting for the Videos library (`videos/`) | `/var/www/var/db/blowfishcms-addons/live/` | `_bfxlive` |
| Videos handed over by add-ons, waiting to be added (`failed/` keeps any that couldn't be, with why, for a week); what happened is in `/var/log/blowfishcms-videos.log` | `/var/www/var/db/blowfishcms/videos-in/` | `_bfadmin`, mode 0700 |
| Add-ons installed apart from releases | `/opt/blowfishcms-addons` | root |
| The site's own files (served as they are) | `/opt/blowfishcms-files` | root |
| httpd configuration | `/etc/httpd.d/blowfishcms.conf`, included from `/etc/httpd.conf` | root |
| Backups and kept releases | `/var/backups/blowfishcms` | root, mode 0700 |

`/var/www` is httpd's chroot, so the settings file names folders as seen from
inside it: `data = /var/db/blowfishcms` means `/var/www/var/db/blowfishcms`.

### Services and accounts

The same code runs as several FastCGI services, each under its own account
and able to touch only what it needs:

| Service | Account | Serves | Can write |
|---|---|---|---|
| `blowfish_public` | `_bfpublic` | the public pages | nothing (reads the catalogue) |
| `blowfish_admin` | `_bfadmin` | `/admin/` | the catalogue and media |
| `blowfish_contact` | `_bfcontact` | the contact form and `/admin/mail/` | its own folder and the mail token |
| `blowfish_comments` | `_bfcomments` | comments, likes, `/admin/comments/`, Analytics (`/stats/hit`, `/admin/analytics/`) | the comments database, the Analytics numbers |
| `blowfish_xNAME` | `_bfxNAME` | an add-on with its own service, e.g. `blowfish_xstore` | that add-on's folders |

The services with admin screens (admin, contact, comments and add-on
services) also keep the `_bfstaff` group, so they can read the session key
that proves you've signed in. The public service can't.

Manage them like any OpenBSD service: `rcctl check blowfish_public`,
`rcctl restart blowfish_admin`. `blowfishctl restart` restarts them all.

### Logs

| Log | What's in it |
|---|---|
| `/var/log/daemon` | Services starting, stopping and their errors (`grep blowfish /var/log/daemon`). |
| `/var/www/logs/access.log`, `error.log` | httpd's request logs. |
| `/var/log/blowfishcms-acme.log` | Certificate renewals. |
| `/var/log/blowfishcms-hourly.log` | Add-ons' hourly jobs, such as the GitHub projects sync. |
| `/var/log/blowfishcms-backup.log` | The nightly backup. |
| `/var/log/blowfishcms-requests.log` | Updates, rollbacks, backups and add-on installs asked for in the admin (each request's own log is shown on the System screen too). |
| `/var/www/var/db/blowfishcms-contact/contact.log` | Mail deliveries (also shown on the Mail screen). |

newsyslog rotates the BlowfishCMS logs.

### Scheduled jobs

Install adds a block to root's crontab, between `# BEGIN BlowfishCMS` and
`# END BlowfishCMS`. Leave those lines alone; updates rewrite the block.

- **Daily:** `blowfishctl certificate` renews the certificate when it's due
  and reloads httpd.
- **Nightly**, between 3 and 4 a.m.: `blowfishctl nightly` makes a backup
  and keeps the newest of its own (see [Backups](#backups)). First it checks
  for updates (`blowfishctl check-updates`): the newest BlowfishCMS release
  where updates come from, and the add-ons' and themes' lists, for the admin's
  notifications, emailing the alerts address set on the Mail screen about
  anything new. Its log is `/var/log/blowfishcms-backup.log`.
- **Hourly:** `site.pl --hourly` runs the hourly jobs of the add-ons that are
  on (GitHub projects syncs here). Its log is `/var/log/blowfishcms-hourly.log`.
- **Every minute:** `blowfishctl requests` carries out what owners asked for
  in the admin (update, roll back, back up on the System screen; install,
  update, switch and remove on the Add-ons screen). It does nothing when
  there's nothing to do. Its log is `/var/log/blowfishcms-requests.log`.

---

## Updating

Releases are published on a site running the Repositories add-on, as the
`blowfishcms` repository's releases (each `blowfishcms-X.Y.Z.tar.gz` and its
`.sha256`); `blowfishcms-addons` and `blowfishcms-themes` hold the archives of
every add-on and theme. Tell the server where that is, once: on the System
screen (**Updates from**), or

```sh
doas blowfishctl updates-from https://example.org/x/repos/   # where updates come from
doas blowfishctl updates-from                                # shows it
```

Then the quickest way to update is the admin's **update to X** button
(below), or on the server:

```sh
doas blowfishctl update latest     # fetch the newest release, check its sha256, update
```

A server with no address looks for no updates. (`/etc/blowfishcms-releases-url`,
`-addons-url` and `-themes-url`, from older setups, still take precedence if
present.) Or copy an archive to the server yourself, then:

```sh
doas blowfishctl update --check /home/you/blowfishcms-X.Y.Z.tar.gz   # optional dry run
doas blowfishctl update /home/you/blowfishcms-X.Y.Z.tar.gz
```

An update does the following:

1. Checks the release: file layout, no symlinks, Unix line endings, and that
   the code compiles.
2. Runs the release's tests (adding python3 first if the server lacks it). First
   `tests/upgrade.py` migrates a copy of your catalogue and checks that
   nothing is lost and that every page you have (on or off), every article and
   every admin screen still works, whatever your site's layout. Then the other
   suites test the code itself on sites of their own, so your pages and
   content can't make them fail. Nothing live is touched; if a test fails, the
   update stops and nothing changes.
3. Snapshots the catalogue into `/var/backups/blowfishcms/releases/<time>/`.
4. Brings the catalogue's tables up to date, then swaps the new code in.
5. Restarts the services and fetches a few addresses every site has (and the
   feed, when Blog is on). If any of that fails, it puts the previous code
   back by itself.
6. Rewrites httpd's configuration with the new release's rules.
7. Puts the add-ons and themes bundled with the release (its
   `catalog/addons` and `catalog/themes`) in the site's lists, and updates
   each one installed that has a newer version there, one at a time; one that
   fails keeps the version it had. Nothing new is installed. (Each release
   does this once.)
8. Keeps the last five releases.

`--check` stops after step 2. `--skip-tests` skips step 2; use it only when
you know why the tests can't run.

**Undoing an update:** `doas blowfishctl rollback` puts back the previous
code. The catalogue is left as it is, because the old code works with newer
tables. Its snapshot from before the update is kept, in case you need it.

### Updating from the admin

Owners can update, roll back and back up from the admin's **System** screen
(see [ADMIN-GUIDE.md](ADMIN-GUIDE.md#system)). Upload `blowfishcms-X.Y.Z.tar.gz`
there; within a minute the server copies it where only root can write and runs
`blowfishctl update` on it, exactly as you would, while the screen shows its
progress and the time left. The request's log records the archive's sha256, so
you can compare it with the one published for the release.

An update runs as root, so anyone who can sign in as an owner can change
anything on the server. Install releases only from a source you trust (the
BlowfishCMS repository), and turn on two-step sign-in for owners.

How it works: the admin service writes requests in
`/var/www/var/db/blowfishcms/system/requests` and uploads in `releases/`; root
writes the results, logs and backup downloads in `results/` and `downloads/`,
which the admin can read but not change. To turn the screen off, so the
server only takes updates from the command line:

```sh
doas touch /etc/blowfishcms-no-system
```

Requests are then thrown away unread. `doas rm /etc/blowfishcms-no-system`
turns it back on.

### Analytics' places

Analytics shows roughly where visitors are by looking their address up in a
city database on the server: DB-IP's free **IP to City Lite** (CC BY 4.0;
the Analytics screen credits DB-IP, as the licence asks). The nightly job
fetches the new month's file from `download.db-ip.com` once a month (last
month's stays until this month's is out), has the comments account check
it, and only then replaces the old one; the comments service picks it up by
itself. Only the place is stored with a view, never the address.

```sh
doas blowfishctl places        # fetch it now (on a new server, say)
```

That's the server's one connection to DB-IP; to use a copy from elsewhere,
put its address in `/etc/blowfishcms-places-url`, with `MONTH` where the
month goes (`2026-11`). Without the file Analytics still counts everything
but places. `doas rm /var/www/var/db/blowfishcms-comments/analytics/places.mmdb`
stops places until the next month's fetch.

### Keeping OpenBSD up to date

BlowfishCMS uses only base OpenBSD and a few Perl packages:

```sh
doas syspatch          # security fixes for the base system
doas pkg_add -u        # package updates
doas blowfishctl restart
```

For a new OpenBSD release, upgrade with `sysupgrade`, then run
`doas pkg_add -u` and `doas blowfishctl restart`. Check that the `xbase` set
was upgraded too: `ls /usr/X11R6/lib/libfreetype.so.*`.

---

## Backups

```sh
doas blowfishctl backup                 # media, catalogue, comments, settings, code, add-on data, site files
doas blowfishctl backup --with-secrets  # also a separate archive of tokens and keys
```

Archives go to `/var/backups/blowfishcms/` with a `.sha256` checksum next to
them. The catalogue and comments are copied with SQLite's own backup feature,
so a backup taken while the site is busy is still consistent.

**Copy backups off the server.** A backup on the same disk doesn't survive
that disk failing. From your own computer, for example:

```sh
scp 'you@server:/var/backups/blowfishcms/blowfishcms-*.tar.gz' ./backups/
```

The secrets archive contains your Postmark token, add-on keys such as
Stripe's, and the keys that sign sessions and forms. Keep it somewhere private, or skip it
and set those again after a restore.

**Nightly backups.** Every night the server makes the same backup by itself
and keeps the newest 14 of its nightly backups, removing older ones. Owners
can turn this off, or keep between 1 and 30, on the admin's System screen,
which also shows how last night went and how much space they take. The
nightly backup never removes backups made by hand or the snapshots updates
take, never runs during an update, and skips a night (saying so on the System
screen) if the disk hasn't room for another. `/var/backups/blowfishcms/nightly.list`
names the backups it made.

Owners can also make a backup and download it from the admin's System screen;
it's the same archive. The three newest are offered there.

Backups made by hand aren't deleted automatically. Remove the ones you've
copied off the server with `doas rm`, or with **delete** on the System
screen.

### Restoring

Each archive includes `_backup/RESTORE.txt` with the exact steps. In short:

1. Install BlowfishCMS on the new server with the **same domain and admin
   name**.
2. Stop the services, then unpack the archive over `/`.
3. Put the catalogue and comments snapshots in place (the commands are in
   `RESTORE.txt`).
4. Set the password and mail token again, or unpack the secrets archive.
5. `doas blowfishctl restart`, and for any add-ons:
   `doas blowfishctl addon enable NAME`.

---

## Add-ons

Every release carries every add-on: installing or updating BlowfishCMS puts
them in the site's list, and owners install, update, switch and remove them
on the admin's Add-ons screen (which files requests for `blowfishctl
requests`, like the System screen). A newer one can also be uploaded there as
a `.tar.gz`. The same from the server:

```sh
doas blowfishctl addon list               # what's installed, and on or off
doas blowfishctl addon add NAME-1.0.0.tar.gz   # put it (or each in it) in the list
doas blowfishctl addon install NAME       # from the list into place
doas blowfishctl addon enable NAME        # switch it on
doas blowfishctl addon update NAME        # the list's newer version
doas blowfishctl addon update --all       # every one with a newer version, one at a time
doas blowfishctl theme update --all       # the same for themes
doas blowfishctl addon disable NAME       # its data is kept
doas blowfishctl addon remove NAME        # once it's off
```

- The list is `/var/backups/blowfishcms/addons-catalog`, one folder per
  add-on. An archive's add-on older than the list's copy is left out.
  Add-ons run with the site's rights, so only add code from a source you
  trust, and read its `addon.json` first: `network` lists every outside host
  it talks to.
- **From an address.** With **Updates from** set (the System screen, or
  `doas blowfishctl updates-from URL`), the server also takes add-ons and
  themes from that Repositories add-on each night; the Add-ons screen shows
  **check now**, and `doas blowfishctl addon refresh` fetches them at once.
- Installed add-ons live in `/opt/blowfishcms-addons/NAME` and survive
  BlowfishCMS updates. An update keeps the copy it replaced as
  `.NAME.previous.<time>` (the newest three); to go back, switch the add-on
  off, move the folder back in its place and switch it on again.
- An add-on whose `addon.json` doesn't suit this release (it needs a newer
  BlowfishCMS, say) isn't installed, and an update that doesn't suit leaves the
  old version in place.
- **remove** keeps the files beside it, renamed `.NAME.removed.<time>`, and its
  data where it was.

**Enabling an add-on that runs its own service** creates:

- the add-on's account and its private folders;
- its rc.d service;
- its httpd addresses.

It then builds the add-on's tables. **Disabling** stops the service and takes
its addresses out of httpd. The add-on's data stays in place.

### Themes

Themes work like add-ons: every release carries them into the themes list
(`/var/backups/blowfishcms/themes-catalog`), from which **Look → Themes**
installs them into `/opt/blowfishcms-themes`; a newer one can be uploaded
there too. On the server:

```sh
doas blowfishctl theme list             # the theme folders, and whether each can be used
doas blowfishctl theme add NAME-1.0.0.tar.gz   # put it (or each in it) in the list
doas blowfishctl theme install NAME     # its variants appear on the Themes tab, hidden
doas blowfishctl theme update NAME      # variants keep their colours and fonts (the editor can reset them)
doas blowfishctl theme remove NAME      # deletes its variants; refused while one is the default
```

Nothing needs restarting: the site reads the folders as they are. A theme
of your own is uploaded the same way, as a `.tar.gz` of its folder (the themes' README describes the
format); `theme list` says whether it can be used.

---

## The site's own files

Some files belong to the site rather than to the code: a resume PDF, a
search engine's verification file, a PGP key, a `security.txt`. Put them in
`/opt/blowfishcms-files`, in the folders they should be served from, then
rebuild the public files:

```sh
doas install -d -m 0755 /opt/blowfishcms-files/cv
doas cp cv.pdf /opt/blowfishcms-files/cv/
doas blowfishctl files        # now served at https://your.domain/cv/cv.pdf
```

Updates and rollbacks bring them along, and backups include them. They never
replace one of the code's own files: names that clash, anything under
`/addons/`, `/assets/`, `/css/` or `/js/`, and hidden names are skipped with a
message. To remove a file, delete it from `/opt/blowfishcms-files` and run
`doas blowfishctl files` again.

Pictures that appear on pages go in the media library instead (the admin
uploads them); this folder is for files that are linked to or fetched as they are.

## Changing the settings file

`/var/www/etc/blowfishcms.conf` holds what belongs to the server rather than
the content: the domain, aliases, admin name and folders. Each line is
`key = value`. Unknown keys and invalid values stop the site with a clear
message, so a mistake can't silently change where data goes.

After editing it:

```sh
doas blowfishctl restart
doas blowfishctl httpd           # if you changed the domain or aliases
doas blowfishctl certificate     # if you changed the domain or aliases
```

Admin users are managed on the admin's **Users** screen, not in this file.
`admin_user` only names the account the site was installed with, which became
its first owner. To give someone a new name, add them as a user and remove
the old one.

---

## Troubleshooting

| Symptom | Look at |
|---|---|
| The site shows "Bad gateway" or a blank page | `doas blowfishctl status`; `grep blowfish /var/log/daemon \| tail` |
| You can't sign in | `doas blowfishctl password NAME` sets your password (a NAME that isn't a user becomes a new owner). Check the `sign-in` line of `blowfishctl status`. |
| "Too many failed sign-ins" | Wait 15 minutes, or `doas blowfishctl unlock` (an owner who's still signed in can press **unlock** under Settings → Sign-in). |
| Lost the phone for two-step sign-in, and the recovery codes | Another owner turns it off for you under Settings → Users, or `doas blowfishctl mfa-off NAME`. |
| The System screen says requests aren't being picked up | Root's crontab has lost its BlowfishCMS lines: `doas blowfishctl httpd` puts them back. |
| A nightly backup failed | The System screen says why; the details are in `/var/log/blowfishcms-backup.log`. |
| The certificate didn't renew | `/var/log/blowfishcms-acme.log`; check the domain still points here and port 80 is open. |
| Contact form says the message wasn't sent | The Mail screen's status and recent deliveries. |
| An admin screen says something "isn't set up" | `doas blowfishctl httpd`; for an add-on, `doas blowfishctl addon enable NAME`. |
| The disk is filling up | `du -sh /var/www/media/blowfishcms/* /var/backups/blowfishcms`; delete old backups you've copied off the server, or keep fewer nightly ones (System screen). |