Add a second box
You can run GurtOS on more than one machine, for example one at home and one in the cloud. Each box is independent: its own tasks, vault, action log and portal. In this guide you name each box, tell one box about the other, and switch between them from the portal.
Before you start
Section titled “Before you start”- Two machines running GurtOS. See Install on Ubuntu or Install GurtOS Server.
- A root shell on each.
- A network route from your browser to both boxes. GurtOS Server from the ISO opens its API to private networks and sets its own
BOX_URL. On the Ubuntu install, see step 2 of Approve from your phone forBOX_LISTEN. - Your browser paired with each box. Off the box itself, every request needs a paired device's token, and each box pairs its own devices.
-
Name each box and give its address. On each machine, set an id, a display name and the address its portal answers on. Without
BOX_ID, the id is the machine's host name, and the name is the id. A GurtOS ISO install names itselfgurt-<id>, from the first 6 hex digits of the SHA-256 of its public key, for examplegurt-bf07fe, so two boxes never share an id.sudo systemctl edit box.service[Service]Environment=BOX_ID=homeEnvironment=BOX_NAME=Home boxEnvironment=BOX_URL=http://192.0.2.10:7700Use a different id, name and address on the second machine, for example
cloud,Cloud boxandhttp://192.0.2.20:7700. -
List the other box as a peer. On the first box, add
BOX_PEERS, a JSON array with one entry per other box.urlis where its portal answers.stdbis the name of its SpacetimeDB database, which isboxunless you changed it.[Service]Environment=BOX_ID=homeEnvironment=BOX_NAME=Home boxEnvironment=BOX_URL=http://192.0.2.10:7700Environment='BOX_PEERS=[{"id":"cloud","name":"Cloud box","url":"http://192.0.2.20:7700","stdb":"box"}]'Do the same on the second box, pointing back at the first, if you want both to list each other.
-
Restart the service on each machine.
sudo systemctl restart box.serviceIf
BOX_PEERSis not valid JSON, the box still starts, lists only itself, and logsBOX_PEERS is not valid JSON. -
Switch boxes. Open the first box's portal. The box switcher in the menu bar, the boxes at the end of the dock, and Settings under Boxes all list both boxes. Choose the other box, and the browser opens that box's own portal. Pair your browser with that box the first time, the same way as a phone. A peer without a
urlshows as "no address yet".
Check it worked
Section titled “Check it worked”curl -s http://127.0.0.1:7700/api/boxes[ { "id": "home", "name": "Home box", "url": "http://192.0.2.10:7700", "stdb": "box", "self": true }, { "id": "cloud", "name": "Cloud box", "url": "http://192.0.2.20:7700", "stdb": "box" }]The first entry is the box you asked. The rest come from BOX_PEERS.
Limits
Section titled “Limits”- Switching opens the other box's portal at its own address. One portal does not show another box's tasks, and approving a request on one box from another box's portal is not built. Open the box that asked.
- The box passes
BOX_PEERSthrough as written. It does not check that a peer is reachable. - Each box keeps its own vault, tasks and log. Nothing is shared or synced between boxes.
Related
Section titled “Related”GurtOS is open source under the Apache License 2.0.Source code on GitHub.