Skip to Content
DocumentationGuidesAuto-update your instance with cron

Auto Update with Cron

You don’t need cron for the Hub stack. Companion Hub checks for a new release once a day and updates its own containers when Auto-update stack is on, which is the default. Cron only matters for the desktop app, which is never updated without a person.

See Updating Companion Hub for the manual update steps for each install method.

What updates itself

Hub has two parts that update separately:

PartUpdatesHow
Hub stack β€” the ci-hub container and its dashboardAutomatically, once a daySettings β†’ System β†’ Auto-update stack is on by default
Desktop app β€” the app and tray, and the bundled cihub CLIOnly when you start itSettings β†’ System, cihub update, or your package manager

The stack update pulls the new Hub image and recreates only the Hub container. It leaves the database and queue containers alone, and your app data, settings, and installed apps carry over.

Your installed apps

Hub never updates your installed apps by itself. On the Hub machine, cihub app update-all asks the running Hub to update every app that has a newer version, taking a backup of each one first. Run it by hand once before you schedule it: it needs the Hub running and the device key that Hub keeps in state/settings.json, so a cron job must run as the account that runs Hub. See Update an installed app.

Which Hubs update themselves

Auto-update moves only a Hub that is pinned to a release image, such as ghcr.io/companionintelligence/ci-hub:0.3.0, and it moves the pin to the newest stable release. It leaves every other Hub alone:

  • A Hub on a channel tag β€” :dev, :staging, or :latest
  • A Hub pinned to an image digest
  • A Hub running a local build or an image from another registry

To move a Hub between channels, change CI_HUB_IMAGE in the Hub env file and recreate the Hub.

Turn auto-update off

Use either of these:

  • In Settings β†’ System, turn off Auto-update stack
  • Set "autoUpdates": false in <ROOT_FOLDER_HOST>/state/settings.json. The value must be the JSON boolean false, not the string "false".

Hub reads the file at each check, so the change applies without a restart.

Updating the desktop app from a script

The desktop app is never updated without a person. Two commands help, but neither is a full cron-driven update:

cihub update --check

Prints a CLI and Hub stack box that names the cihub version and the Hub stack version side by side, then asks the desktop app whether a newer version exists. It exits with status 1 when an update is available. It also exits 1 when the desktop app isn’t installed on the machine, so a script can’t tell those cases apart from the exit code alone.

cihub update

Downloads and installs the new desktop app, then relaunches it. On Linux, the install step asks for administrator authorization, so it isn’t suited to an unattended cron job. On a machine with no desktop app, a standalone cihub binary runs cihub self-update instead, which needs a GH_TOKEN or GITHUB_TOKEN in the environment and only replaces the CLI, not the Hub stack. For a package-manager install, cihub update tells you the command for the channel your cihub came from, such as brew upgrade --cask companion-hub or scoop update companion-hub, and exits 1.

The cihub CLI and the Hub stack are separate updates, and a machine can sit on an old CLI while the stack moves ahead. cihub doctor shows the mismatch on its CLI vs stack line, and cihub version prints the CLI version followed by the running Hub build.

If an update fails

  • <ROOT_FOLDER_HOST>/logs/hub-stack-update.log has one block per attempt. It ends with result=ok or result=failed.
  • Settings β†’ Logs records every refused update as Hub stack update refused: and every skipped daily check as Auto-update skipped:. It also records each update the daily check starts, as Auto-update: updating the Hub image only, from <old> to <new>, which is a reminder that the desktop app update is yours to make in Settings.
Last updated on