Ports CoreDesktop's e991264, 05b13b2 and d974b91. configure agents allowed Hermes' gateway the host in MATRIX_HOMESERVER from ~/.hermes/.env, which Hermes can write from inside its sandbox, so it could open the way out to any host it chose. The allowed server is now in ~/.config/federated-connector/sandbox/hermes.json, which no sandbox can write. configure hermes is to do while Hermes names a server you haven't allowed, and asks about only that; configure agents says so. Only a plain host name counts, so it can't be a wildcard or carry escape codes into the question. sandbox/agent no longer reads FEDERATED_SANDBOX_DOMAINS. The server an old drop-in allows is carried over, read from the drop-in itself, when the gateway starts and when configure agents rewrites it, so a working gateway keeps working. Agents could read ~/.config/federated-connector, which has the Core's domain and user name; base.json now hides it. edit_json treats an empty settings file like a missing one: jq reads no JSON from an empty file and writes nothing back, so configure ai-servers said a server was added while the sandbox still blocked it. agent_path joined the last folder on PATH to ~/.local/bin, so an agent there wasn't found when ~/.local/bin wasn't on PATH (e.g. in a service). Smoketest: 55-hermes-homeserver, and 50-sandbox checks that an agent can't read the connector's settings. PLAN.md drops what's done. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
182 lines
16 KiB
Markdown
182 lines
16 KiB
Markdown
# Federated Connector for Pop!_OS
|
|
|
|
Sets up a Pop!_OS computer for your Federated Core. It's the Pop!_OS counterpart of [CoreDesktop](https://gitea.federated.computer/Federated_Computer/coredesktop)'s `configure`, with the same items, and works the same way: it shows what's set up, sets up the rest, and can test and fix a Core later.
|
|
|
|
## Requirements
|
|
|
|
- Pop!_OS 24.04 with COSMIC. Most of it works on other Ubuntu 24.04-based systems too; `configure` says so if it's run on one.
|
|
- An administrator account (in the `sudo` group): `configure` installs packages and changes system settings such as mounts, printers and Tailscale.
|
|
|
|
## Installing
|
|
|
|
In a terminal:
|
|
|
|
```
|
|
curl -fsSL https://federated.sh/pop | bash
|
|
```
|
|
|
|
federated.sh/pop sends curl to [install.sh](install.sh) here on Gitea, so you can read what it runs first. In a browser, it opens this page.
|
|
|
|
It checks the computer first: Linux with apt, not run as root, and an internet connection. It warns if this isn't Pop!_OS, or if your account isn't an administrator. Then it:
|
|
|
|
- installs the few packages `configure` itself needs: curl, jq, libsecret-tools, python3-gi, gir1.2-secret-1 and libnotify-bin
|
|
- downloads the latest version into `~/.local/share/federated-connector/connector`. Pop!_OS doesn't come with git, so it downloads an archive.
|
|
- adds the `configure` and `update` commands to `~/.local/bin`
|
|
- makes sure `~/.local/bin` is on your PATH, at the top of `~/.bashrc`
|
|
- offers to run `configure`
|
|
|
|
Running it again reinstalls the latest version. The logs are in `~/.local/state/federated-connector/`.
|
|
|
|
The install's folder never moves. That matters because the backup, email-watch and network storage services point into it.
|
|
|
|
## Running it
|
|
|
|
```
|
|
configure # show what's set up and choose what to set up
|
|
configure core # set up one item
|
|
configure --list # show what's set up, and the item names
|
|
```
|
|
|
|
## Updating
|
|
|
|
```
|
|
update # get the latest version, showing what changed
|
|
update --version # the version installed
|
|
```
|
|
|
|
`update` downloads the latest version and swaps it in at once, so it's safe while a backup runs. It brings the services `configure` set up up to date too. Your settings, accounts, keyring items and downloaded tools stay as they are.
|
|
|
|
Everything `configure` installs from apt (Evolution, davfs2, restic, Tailscale, mise...) is updated by Pop!_OS' own updates, in the COSMIC Store or with `sudo apt upgrade`. Flatpak apps such as Element update there too.
|
|
|
|
## What it sets up
|
|
|
|
Each item installs what it needs the first time you set it up, after asking.
|
|
|
|
- **Your Federated Core.** Give it your Superpanel's address (e.g. https://superpanel.example.com), your Core email, name and password. It sets up:
|
|
- **Email, calendars and contacts**, shown in Evolution. COSMIC doesn't have online accounts of its own yet, so `configure` installs GNOME Online Accounts and Evolution and adds the accounts the way GNOME Settings would. GNOME Online Accounts runs on its own, without GNOME. Your passwords are kept in your keyring, which COSMIC unlocks when you log in.
|
|
- Email keeps your Core password, because the mail server doesn't take Nextcloud app passwords. Its settings come from the mail server's autoconfig, or the usual ones if the server doesn't publish them.
|
|
- Calendars and contacts use a Nextcloud app password, "Pop!_OS on {your computer}", which you can revoke in Nextcloud under Settings > Security.
|
|
- **Superpanel** in your applications (the COSMIC launcher and app library), with Superpanel's own icon.
|
|
- **Your Nextcloud files**, mounted at /mnt/example.com with davfs2, and shown in the COSMIC Files sidebar as "example.com". `configure` makes `mount.davfs` setuid and adds you to the `davfs2` group, so you can mount it without sudo. It mounts when you log in.
|
|
- **Element**, pointed at your Core's Matrix server, for your main Core. If Element isn't installed, it offers to install it from Flathub, as the COSMIC Store would.
|
|
- **Tally for Plausible**, if it's installed and your main Core runs Plausible Analytics: it's pointed at plausible.example.com.
|
|
- **An email watcher**, a user service that pauses your Core's email if its password stops working (see below).
|
|
|
|
You can add more Cores: run `configure core` again and choose "Add a Core". Each gets its own Superpanel, accounts and files. Element, Tailscale and backups use your main Core (the first one, unless you choose another).
|
|
|
|
`configure core` also offers:
|
|
- **Test a Core**: it checks Superpanel, calendars and contacts, email, your files, Element and backups the way this computer uses them, says which work, and offers to fix those that don't. If a fix needs it, for example a new app password for one that was revoked, it asks for your Core password. Then it tests again.
|
|
- **Your Core password changed**: email gets the new password, and signing in to Nextcloud with it turns the app passwords for calendars, contacts, files and backups back on (Nextcloud turns them off when your password changes). Then it checks each of them.
|
|
- **Remove a Core**: it removes the accounts, the mount and Superpanel, and revokes the app password. Everything on the Core itself stays as it is.
|
|
- **Tailscale**: joins this computer to your Core's Tailscale network through headscale.example.com. If Tailscale isn't installed, it installs it from Tailscale's own apt repository. You can use `tailscale` without sudo afterwards. To leave the network, run `configure tailscale` again.
|
|
- **Backup**: backs up your home folder daily to your Nextcloud files, in a `.backup-{computer name}` folder, with restic (from Ubuntu's packages).
|
|
- The backup is encrypted with a passphrase that `configure` shows you once. Save it somewhere other than this computer, such as Bitwarden.
|
|
- It keeps 7 daily, 4 weekly and 6 monthly backups. It leaves out caches, things that can be reinstalled, and Flatpak apps' caches. To leave out more, list paths in `~/.config/federated-connector/backup-exclude`, one per line.
|
|
- restic reaches Nextcloud directly through rclone, with its own Nextcloud app password ("Federated Backup on {your computer}"), so the backup doesn't depend on the /mnt mount.
|
|
- A systemd user timer runs it, and catches up at your next login if the computer was off. If a backup fails, you get a notification. To follow one: `journalctl --user -fu federated-connector-backup`.
|
|
- To turn backups off, run `configure backup` again. It also offers to delete the backups from your Nextcloud files (they go to Nextcloud's trash bin).
|
|
- **AI agents**: offers to install Claude Code, opencode and Hermes Agent with each one's own installer, and runs them in a sandbox (see below). `configure claude`, `configure opencode` and `configure hermes` sign in to them and choose their model providers.
|
|
- **Languages**: installs programming languages and tools with [mise](https://mise.jdx.dev), from mise's own apt repository: Ruby on Rails, or any tool mise knows (`mise registry` lists them), such as `node@lts` or `java@21`. To update them: `mise upgrade`. To remove one: `mise unuse -g <tool>`.
|
|
- **AI servers**: LLM servers on your network, such as Ollama on a Mac. It finds the machines on your network over mDNS and asks each one on the ports LLM servers use (11434 Ollama, 1234 LM Studio, 8080 llama.cpp, 8000 vLLM), since LLM servers don't announce themselves. Or you enter a server's address. For the server you choose, it:
|
|
- lets the sandboxed agents reach it (that port only)
|
|
- adds it to opencode with its models
|
|
- offers to make it Hermes' model
|
|
- lets the commands Claude Code runs reach it too
|
|
|
|
A server has to accept connections from other machines: in Ollama's settings, turn on "Expose Ollama to the network"; in LM Studio, "Serve on Local Network".
|
|
- **Printers** on your network. It lists the printers it finds, whether they're reached directly or shared by another computer, and adds the ones you choose as printers on this computer, without drivers (IPP Everywhere), so they're in every print dialog. A printer another computer shares that can also be reached directly is marked, and not chosen unless you pick it. Printers already added (e.g. by cups-browsed) are left alone. To choose without being asked, set a default printer or print a test page, run `~/.local/share/federated-connector/connector/system/setup-printers.sh --help`.
|
|
- **Network storage**: shared folders from other machines on your network, mounted in /mnt and added to the COSMIC Files sidebar. It finds SMB servers (Windows, Samba and NAS boxes, and Macs with File Sharing on) and machines you can ssh to. Or you enter an address (`smb://nas.local/files`, `sftp://me@server.local/srv/data`).
|
|
- An SMB share is in /etc/fstab and mounts the first time you open its folder, so a server that's off doesn't hold anything up. Its password is kept in /etc/federated-connector/smb, readable only by root.
|
|
- An SFTP folder is mounted by sshfs as you, at login, with the SSH keys in your Bitwarden SSH agent or your keyring's, so the server has to accept one of them (it can't ask for a password).
|
|
- "Remove one" unmounts it and takes it back out.
|
|
- **Agent sandbox**, if WinBoat is set up: the sandbox hides WinBoat's settings (~/.winboat) from agents, since they include your Windows password. To let agents read them, run `configure sandbox` and switch it; switch it again to hide them.
|
|
|
|
### When your Core password changes
|
|
|
|
Your email keeps your Core password, so after you change it (e.g. in Superpanel), the mail server starts refusing the old one. Online Accounts tries it again each time your network changes, and Evolution each time it fetches mail. After a few wrong passwords, the mail server blocks this computer for a while.
|
|
|
|
So the email watcher watches for it, without ever trying the password on the mail server:
|
|
|
|
1. When your password changes, Nextcloud stops accepting the app passwords this computer uses, and Online Accounts notices.
|
|
2. The watcher then checks the password your email has with Nextcloud, once.
|
|
3. If Nextcloud says it's wrong, the watcher pauses your email: this computer stops trying the old password, and you get a notification.
|
|
|
|
Click the notification to open `configure core` in COSMIC Terminal, choose "Your Core password changed" and enter your new password; that ends the pause.
|
|
|
|
The Online Accounts that Pop!_OS 24.04 has (3.50) also flags an account when its server just can't be reached. The watcher and "Test a Core" don't take that to mean a wrong password: they check with Nextcloud first, and do nothing if Nextcloud can't be reached either.
|
|
|
|
### Restoring from a backup
|
|
|
|
To see the backups and get files back:
|
|
|
|
```
|
|
source ~/.local/share/federated-connector/connector/system/backup-env.sh
|
|
restic snapshots
|
|
restic restore latest --target ~/restored --include ~/Documents
|
|
```
|
|
|
|
On a new computer, run `configure core` and `configure backup` first. Then name the old computer's folder, and restic asks for the passphrase you saved:
|
|
|
|
```
|
|
source ~/.local/share/federated-connector/connector/system/backup-env.sh .backup-{old computer's name}
|
|
restic snapshots
|
|
```
|
|
|
|
## Sandboxed AI agents
|
|
|
|
opencode, Hermes and Cline Desktop run in Anthropic's sandbox runtime (srt), which uses bubblewrap. In the sandbox, an agent:
|
|
|
|
- can change files only in the folder you start it in (plus its own settings, /tmp and a few package caches), so start it from a project folder
|
|
- can't read your SSH keys, keyrings, password managers, browser profiles, Evolution's mail, calendars and contacts, Thunderbird, Element, cloud and Git credentials, the other agents' logins, or Federated Connector's settings (your Core's domain and user name, and what the sandbox allows)
|
|
- can reach only AI providers and common developer sites: GitHub, Gitea, npm, PyPI, crates.io, RubyGems, the Go module proxy, and Ubuntu's and Pop!_OS' sites
|
|
|
|
Typing `opencode`, `hermes` or `hermes-agent` runs it in the sandbox: `configure agents` adds a block at the end of ~/.bashrc that puts `sandbox/bin` first on PATH. To run one without the sandbox, type `unsandboxed opencode`. Claude Code uses its own built-in sandbox, also on bubblewrap, for every command it runs, which `configure agents` turns on (see `/sandbox` inside Claude). If you had no Claude Code settings, it also adds notifications for when Claude needs you and when it's done.
|
|
|
|
If Hermes' gateway is set up as a service, `configure agents` runs it in the sandbox too. Hermes can change its own settings from inside the sandbox, so the Matrix server they name isn't trusted on its own: `configure hermes` asks whether it's your server and may be reached, and keeps your answer in `~/.config/federated-connector/sandbox/hermes.json`, which no sandbox can read or write. For other messaging services, add their domains to that file as shown below. If Cline Desktop is installed, its entry in the app library opens it in the sandbox.
|
|
|
|
srt needs Node.js 22.12 or later, and Pop!_OS 24.04's is older. Unless a new enough one is installed already, `configure agents` downloads the current LTS from nodejs.org into `~/.local/share/federated-connector/node`, checks it against the SHA-256 sums nodejs.org publishes, and uses it only for srt.
|
|
|
|
Ubuntu 24.04 lets only programs AppArmor allows make the user namespaces bubblewrap needs. If that stops the sandbox here, `configure agents` offers to add an AppArmor profile for `/usr/bin/bwrap` (`/etc/apparmor.d/federated-connector-bwrap`), as Ubuntu suggests.
|
|
|
|
To allow more, put a file in the same format as `sandbox/config/base.json` in `~/.config/federated-connector/sandbox/`: `base.json` for every agent, or `<agent>.json` for one. Lists in it are added to the built-in ones.
|
|
|
|
## Where things are
|
|
|
|
- Your answers: `~/.config/federated-connector/`. That's `cores/<domain>.conf`, `core.conf` for the main Core, `tailscale.conf`, `backup.conf`, `storage`, `ai-servers`, `printers`, `languages`, `agents`, and your own `sandbox/` config.
|
|
- Accounts: GNOME Online Accounts (`~/.config/goa-1.0/accounts.conf`), with their passwords in your keyring
|
|
- The backup's app password and passphrase: your keyring, attributes `federated-connector backup`
|
|
- Your files' app password: `~/.davfs2/secrets`
|
|
- Services: `~/.config/systemd/user/federated-connector-{backup.service,backup.timer,email-watch.service,sftp-*.service}`
|
|
- The Files sidebar: `~/.config/cosmic/com.system76.CosmicFiles/v1/favorites`, and `~/.config/gtk-3.0/bookmarks` for GTK apps
|
|
- Federated Connector itself: `~/.local/share/federated-connector/connector`, with `configure` and `update` linked in `~/.local/bin`
|
|
- Downloaded tools: `~/.local/share/federated-connector` (`node`, `srt`)
|
|
|
|
## Adding an item
|
|
|
|
Each file in `configure.d/` is one item. It sets `TITLE` and `DESCRIPTION` and defines `is_configured` and `run_configure`. It can also define `is_installed`, and the item is left out when that fails. Items get `CONNECTOR`, `CONF_DIR`, `confirm` and `confirm_yes` from `configure`, and `pkg_ensure` to install what they need. Libraries are in `configure.d/lib/`:
|
|
|
|
- `packages.sh`: apt packages and Flatpak apps
|
|
- `goa-account`: accounts in GNOME Online Accounts
|
|
- `nextcloud.sh`: app passwords
|
|
- `sidebar.sh` and `cosmic-favorites`: the Files sidebar
|
|
- `json.sh`: editing JSON settings files
|
|
- `mdns.sh`: finding things on the network with Avahi
|
|
- `agents.sh`: the agents' real commands and srt
|
|
- `tools.sh`: Node.js and srt
|
|
|
|
`system/` has what runs in the background (`backup`, `email-watch`, `sftp-mount`) and their systemd units, and `sandbox/` has the sandbox wrapper and its config.
|
|
|
|
## Testing
|
|
|
|
`make lint` runs shellcheck. `smoketest/run` runs the scenarios in `smoketest/`, each in a fresh Ubuntu 24.04 container with Docker. See [smoketest/README.md](smoketest/README.md).
|
|
|
|
## Differences from CoreDesktop
|
|
|
|
- Email, calendars and contacts are shown in Evolution, as COSMIC has no Online Accounts of its own. CoreDesktop adds them to GNOME's Settings.
|
|
- What each item needs is installed when you set it up, from apt, Flathub or the tool's own apt repository, rather than all at install time.
|
|
- The Files sidebar is COSMIC Files'; folders are added to GTK's bookmarks too.
|
|
- davfs2 mounts need Ubuntu's setuid `mount.davfs` and the `davfs2` group, where Arch uses the `network` group.
|
|
- Languages come from mise's apt repository, and nothing is installed with it up front. CoreDesktop's `update` upgrades them; here, run `mise upgrade`.
|
|
- The agents are installed by `configure agents`, and srt runs on its own Node.js. On Ubuntu, bubblewrap may need an AppArmor profile.
|
|
- `update` updates only Federated Connector; Pop!_OS updates the rest.
|