Black Branch/Docs
All sections

Installing

This page is for the person running the installer. After it, your server will be running Black Branch and you will have the setup link. It assumes you have done the checks on Before you start, and in tunnel mode that your domain is active on Cloudflare (Putting your domain on Cloudflare).

Two ways to get the software

The one-line form A copy of the source
What you run curl -fsSL https://blackbranch.app/install.sh | sudo bash git clone, then sudo ./install/install.sh
What you get The newest published release, checked before it is unpacked Whatever is in that copy; the install calls it local
The site's software Downloaded as one ready-made image, the same for every install Built on your server once, which takes most of a 4 GB server's memory
Updates Follows the beta channel, where every release so far is published Follows the stable channel; switch it to beta to receive the previews

Every release so far is a preview on the beta channel. The releases, with their sizes, checksums and the signing key, are listed at blackbranch.app/releases.

The one-line form

curl -fsSL https://blackbranch.app/install.sh | sudo bash

Until the first stable release, this installs the beta, and your server follows the beta channel.

You can answer the installer's two questions up front, so it asks nothing:

curl -fsSL https://blackbranch.app/install.sh \
  | sudo bash -s -- --domain example.com --mode tunnel

Read a script before you run it as root. Piping into sudo bash runs whatever arrives. To read it first, download it, read it, then run it:

curl -fsSLO https://blackbranch.app/install.sh
less install.sh
sudo bash install.sh

Run as a file like this, it behaves exactly like the piped form.

What the script does: it is a copy of the installer stamped with one release, its version number, the size of its download and that download's sha256 fingerprint. It then:

  1. Refuses to go on if this server already runs another release (see Running it again).
  2. Downloads blackbranch-<version>.tar.gz over HTTPS, refusing anything larger than the stamped size.
  3. Checks the download's size and sha256 against the stamp. A mismatch stops everything with "nothing was installed".
  4. Checks what is inside: only plain files and folders under one top folder, nothing that runs with special privileges, and a RELEASE file naming the same version.
  5. Unpacks it as /opt/blackbranch/releases/<version>/ and runs the installer inside it, with the same options.

How you know the software is genuine

Three checks protect you, at three different moments:

For a test of your own, --release-key <key or file> makes the server trust another key, and --update-feed <address> reads releases from another address. Both are written once, when the settings file is made.

From a copy of the source

git clone https://github.com/Black-Branch/blackbranch.git blackbranch
cd blackbranch
sudo ./install/install.sh

The copy is the release: the installer copies it to /opt/blackbranch/releases/local/ and builds every image on the server, including the site's. On a server with less than about 7.5 GB of memory and no swap, it adds a 2 GB swap file (/swapfile.blackbranch) first, so the build is slow rather than killed. --no-swap turns that off.

A server installed this way follows the stable channel, whose first release is still to come. To receive the previews as updates, run this once setup is done:

sudo blackbranch update --channel beta

Run the installer

The one-line form runs it for you. It asks two questions:

  1. Your site's domain: example.com, with no https:// and no www..
  2. Front door: tunnel or direct. Pressing Enter picks tunnel.

Every question has an option, so the installer can run without asking. --help prints them all:

Option What it does
--domain <name> The site's domain. Permanent.
--mode tunnel|direct The front door. Permanent. (internal also exists: a lab mode for a test server with no public domain, using certificates no browser trusts. Never for a real site.)
--site-name <text> The site's name until the setup pages set it. Default: the domain.
--tunnel-token Tunnel mode with a tunnel made in Cloudflare's dashboard: asks for its token without showing it. See a dashboard tunnel.
--tunnel-token-file <file> The same, reading the token from a file.
--acme-email <address> Direct mode: the email address Let's Encrypt may write to about your certificates. Optional.
--skip-dns-check Direct mode: do not require the three names to resolve before installing.
--moving This server takes over a site from its backup: it installs everything but makes no tunnel, starts nothing and prints no setup link. See Moving to a new server.
--no-swap Never add the swap file.
--release-key, --update-feed, --update-channel stable|beta Which key, feed address and channel this server trusts and follows. Written once.

Direct mode: point the three names first

In direct mode the server gets its own certificates from Let's Encrypt, which only works once the names lead to it. Direct mode is tested end to end like the tunnel: a fresh public server installed, received certificates for all three names, finished setup and took an update through the feed. Before you run the installer, create a DNS record for each of the three names at your DNS provider:

Name Type Value
example.com A your server's public IPv4 address
api.example.com A the same
matrix.example.com A the same

Add an AAAA record with the IPv6 address too, if the server has one. The installer looks each name up and stops if one does not resolve. If a name points at an address that is not this server's, it says so and carries on, because a home router that forwards the ports is a normal setup.

Make sure ports 80 and 443 (TCP, and UDP 443 for HTTP/3) reach the server: open them in your provider's firewall, or forward them on a home router. Port 80 is needed even though the site runs on HTTPS, because Let's Encrypt checks it when it issues and renews a certificate.

What the installer does

It prints each stage as a heading. In order:

  1. Checks the server: Debian or Ubuntu, x86-64, enough memory. Nothing has changed yet if one of these fails.
  2. Installs what it needs: ca-certificates, curl, rsync, openssl and unattended-upgrades.
  3. Checks it can reach the image registry (ghcr.io, IPv4 only). A server with IPv6 alone stops here, with nothing installed.
  4. Installs Docker Engine and its Compose plugin from Docker's own package repository, if they are missing. A Compose plugin older than 2.20 is refused, with the command to update it.
  5. Turns on automatic security updates for the operating system, once. If you change that setting later, the installer leaves your choice alone. The Doctor shows a red row if they are off.
  6. Asks the two questions (or takes them from the options).
  7. Copies the release to /opt/blackbranch/releases/<version>/ and points /opt/blackbranch/release at it. Each release keeps its own folder, so an update can go back to the one before.
  8. Writes the settings file, /opt/blackbranch/.env, once: the domain, the addresses made from it, and a fresh random value for every secret. The file is readable by root only and its secrets are never printed. Every value is explained on The install's settings file.
  9. Installs the blackbranch command at /usr/local/bin/blackbranch, and the background services that run backups, updates and the site's requests to the server.
  10. Sets up the front door: in tunnel mode the Cloudflare sign-in and tunnel (the sign-in); in direct mode the DNS check.
  11. Brings everything up, in a fixed order: the database and its migrations, the setup link's token, the router's and the homeserver's configuration, the homeserver's signing key (once), Synapse and its sign-in service, the chat and ingest services, the site, the router and, in tunnel mode, cloudflared. It waits until every service reports healthy. See The homeserver.
  12. Reads the update feed once, so the Doctor has an answer from the start.
  13. Prints the setup link.

From a release this takes about two to three minutes on a 2-core, 4 GB server, most of it downloading images. A slow connection takes longer, and a copy of the source adds the time to build the site.

What you see at the end

== Installed
   site        https://example.com
   api         https://api.example.com
   homeserver  https://matrix.example.com   (server name example.com — permanent; federation off)
   values      /opt/blackbranch/.env  (back it up — its secrets exist nowhere else)
   operate     sudo blackbranch status · sudo blackbranch logs <service> · sudo blackbranch backup · blackbranch help
               (every command but help needs sudo: the install is root's)

   Open this link to set up your site (it works once, until the first admin exists):

   https://example.com/setup?token=…

Until setup is finished, every page of your site shows "this site is being set up" to everyone else.

⚠ Keep the setup link to yourself. Until your account exists, whoever opens it can make the site's admin account. Do not paste it into a chat, an issue or a screenshot.

If the install stops

Tell the two kinds of failure apart by who is speaking:

If a service does not become healthy at the end, the line names it. sudo blackbranch status shows every service's state, and sudo blackbranch logs <service> its recent log (see Logs and restarts). The full list of messages is on Troubleshooting. If the message does not tell you what to do, ask in the Discord or open a setup-help issue, and attach sudo blackbranch doctor --report.

Running it again

Running the installer again is safe, and it is the way to repair an install:

It refuses, before it changes anything, when you ask for something an install cannot do:

Refusal Why
"this box is installed for …; the domain cannot change" The homeserver is named after the domain.
"changing the mode is not supported yet" The front door is fixed when the install is made.
"this box runs release X; this installer is Y" An installed server moves between releases only through sudo blackbranch update, which backs up first and goes back if the new release fails. Running the installer of the release you already run repairs it.
"never install an older release over a newer one" The database may already be at the newer release's version.
"this box already trusts another release key" A server keeps the key it was installed with.
"blackbranch update is running" An update holds the same lock. The installer waits up to a minute, then stops; run it again once sudo blackbranch status shows the update finished.

Where things are on the server

Path What it is
/opt/blackbranch/.env The install's values and every secret. Root only. Back it up off the server.
/opt/blackbranch/compose.yaml The list of services Docker runs
/opt/blackbranch/releases/<version>/ Each release's files; release points at the one in use
/opt/blackbranch/rendered/ The router's and the homeserver's configuration, generated from .env. Edits here do not last: every render overwrites them.
/opt/blackbranch/matrix/mas-keys.yaml The sign-in service's signing keys, made once. In every backup.
/opt/blackbranch/cloudflared/ Tunnel mode: the tunnel's settings and credentials
/opt/blackbranch/backups/ Backups kept on this server, when that is the target
/opt/blackbranch/site-files/ Your own icons, served at /site-files/ (see Site name, theme and looks)
/opt/blackbranch/requests/, results/ How the site asks the server for a fixed action, and reads the answer (see The server command)
/opt/blackbranch/state/ The command's own records: the setup token, locks, update progress
/usr/local/bin/blackbranch The server command (reference)

The folder /opt/blackbranch belongs to root and nobody else can enter it. If an ordinary account on your server shares a user number with one of the services (for example number 1000, which is often the first account made and is also the site's), the installer says so. That account still cannot reach the files, but do not give it other secrets.

Next: The setup pages

← Install