# Tilecast Managed

Tilecast Managed runs Tilecast Server on a dedicated Debian or Ubuntu computer. A system service, the **Tilecast Supervisor**, installs the Server and PostgreSQL in Docker, keeps them running, verifies and installs updates, and takes backups. You manage it from Studio or with the `tilecast-admin` command on the host.

<ManagedStatus platforms />

If Managed isn't released for your host, install with [Tilecast Container](../../installation/). [Choose an installation method](../../setup/installation-methods/) compares the two.

## Requirements

- A Debian or Ubuntu host with systemd marked as Qualified in the table above.
- At least 2 GB of memory and 10 GB of free space in `/var/lib`. Media and backups need more.
- A computer that runs nothing else in Docker under the Compose project name `tilecast`.
- Outbound HTTPS to `ghcr.io`, `github.com`, and `tuf.tilecast.org` during installation and updates.
- Docker Engine 25 or later. The installer can install it from Docker's repository if you agree.

## Install Tilecast Managed

Download the installer, read it, then run it with `sudo`.

```sh title="On the Tilecast host"
curl -fsSL https://tilecast.org/install-managed.sh -o install-managed.sh
```

```sh
sudo bash install-managed.sh
```

`install-managed.sh` downloads the installer of the released version, checks its SHA-256, and runs it. The site bootstrap relies on HTTPS for its first download. To authenticate the release installer independently, download `tilecast-managed-install.sh` and its `.sigstore.json` bundle from the release page. Set `COMMIT` to the source commit for the intended release. Verify with an independently installed GitHub CLI.

```sh
gh attestation verify tilecast-managed-install.sh \
  --bundle tilecast-managed-install.sh.sigstore.json --repo gbyo/tilecast \
  --signer-workflow gbyo/tilecast/.github/workflows/supervisor-release.yml \
  --source-ref refs/heads/main --source-digest "$COMMIT" \
  --predicate-type https://slsa.dev/provenance/v1
```

After verification succeeds, run the verified copy with `sudo bash tilecast-managed-install.sh`. Its package digests bind the packages it installs before the Supervisor can verify TUF metadata.

The installer checks the host, asks before it installs Docker Engine, installs the `tilecast-supervisor` package after it checks the package digest, verifies the signed release information, and starts Tilecast. It never adds an account to the `docker` group, never changes firewall rules, and never changes other Docker containers.

Common options:

| Option                | Use                                                                                                                                          |
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `--install-docker`    | Install Docker Engine from Docker's repository without asking.                                                                               |
| `--yes`               | Ask no questions. Without `--install-docker`, a missing Docker Engine stops the installation.                                                |
| `--port PORT`         | Use another host port than 8080.                                                                                                             |
| `--bind ADDRESS:PORT` | Publish Tilecast on this address. Repeat for more. The default is `127.0.0.1` and the private LAN address. A public address is never chosen. |
| `--public-url URL`    | The address that browsers and Players use.                                                                                                   |
| `--channel beta`      | Follow Beta releases. Use it only for testing.                                                                                               |

Run `sudo bash install-managed.sh --help` for every option. If the installation stops, fix the problem it reports and run the same command again. It continues from where it stopped.

## Finish setup in Studio

The installer prints the address of Studio and a one-time **setup code**. The code is valid for 24 hours.

1. Open the address in a browser on the same network.

2. Enter the setup code, your organization name, and the Owner account.

If you lost the code, print a new one on the host:

```sh
sudo tilecast-admin setup-code
```

LAN discovery needs the Avahi daemon. The installer doesn't install it. Install `avahi-daemon` if you want Players to find the Server without typing its address.

## Update Tilecast

Studio shows available updates under **Updates**. An update takes a backup first, installs the new Server image only after its signature and provenance verify, and returns to the previous version if the new one does not start.

On the host:

```sh
sudo tilecast-admin update check
```

```sh
sudo tilecast-admin update plan
```

The plan names the offered version and what the update changes. Install that version:

```sh
sudo tilecast-admin update install VERSION
```

`sudo tilecast-admin update status` shows the installed version and the update policy.

## Back up and restore

Create a backup from Studio under **Backups**, or on the host:

```sh
sudo tilecast-admin backup create
```

```sh
sudo tilecast-admin backup list
```

To restore an archive of this installation, run `sudo tilecast-admin backup restore ARCHIVE`. Tilecast Server stops during the restore and keeps a backup of the state it replaces.

If a restore cannot confirm that the data is intact, Tilecast Server stays stopped, even after a restart. Run `sudo tilecast-admin repair` to retry offline recovery before starting the Server.

Archives stay on the host until you copy them somewhere else. Configure an off-site Restic repository in Studio to keep copies on another computer or service, then check it with `sudo tilecast-admin backup offsite status`. Keep the repository password somewhere other than the Tilecast host.

## Move from Tilecast Container

Run the Tilecast Managed installer on the host of a Tilecast Container installation. The installer finds the Compose project `tilecast` and asks whether to adopt it. Nothing changes until you accept the adoption plan.

The adoption takes a backup first, keeps your users, Players, content, history, and settings, and never removes the Container volumes. Paired Players keep working. Until the move finishes, a failure returns the Container installation to how it was.

If you use a custom Player release signing policy, Tilecast carries the public policy over when you adopt or return to Tilecast Container.

Check the move with `sudo tilecast-admin adopt status`. To return to Tilecast Container later, run `sudo tilecast-admin detach plan` and then `sudo tilecast-admin detach apply`.

## Troubleshoot

```sh
sudo tilecast-admin status
```

```sh
sudo tilecast-admin doctor
```

- `sudo tilecast-admin logs server` shows the Server output.
- `sudo tilecast-admin repair` puts the containers back into the state the Supervisor expects.
- `journalctl -u tilecast-supervisor` shows what the Supervisor did.

## Remove Tilecast Managed

```sh
sudo apt-get remove tilecast-supervisor
```

Removing the package stops Tilecast and the Supervisor. It deletes nothing: the database, media, keys, and settings stay on the host, and installing the package again resumes the same installation. `apt-get purge` also keeps `/etc/tilecast`, `/var/lib/tilecast`, and the Docker volumes, because your data can't be read without the keys in `/etc/tilecast`.

Delete those only after you have copied a backup and its keys somewhere else.

For the engineering contract, see [Tilecast Managed](https://github.com/gbyo/tilecast/blob/main/docs/tilecast-managed.md) in the repository.
