Page kind: Reference
swarmops update#
Replace this program, swarmops and so, with the latest release, or set automatic update. Touches no store and never runs upgrade.
Without a flag it reads the latest release from where GitHub's releases page redirects, and when that is newer than what is installed it downloads the release, checks it against the release's SHA256SUMS, runs the new binaries once, and renames them over the old ones, swarmops first: updated is true and previous is the version replaced. A latest release that is not newer installs nothing and is no error; an older version or a pre-release is never installed. Running MCP servers keep the program they started with until they are restarted.
It works on an install the installer made, which left a receipt beside the binaries (.swarmops-receipt), in a release's build. Any other install is refused as E_INVALID_ARG, details.reason no_receipt or not_a_release_build, and is updated the way it was installed: by its package, or by building again. Nothing that turns automatic update off stops this command.
It runs the host's curl for the one request of its own (SWARMOPS_CURL by an absolute path, else the first on PATH; none is details.reason curl_missing), and the installer built into this program, under /bin/sh, with the tools that needs: curl or wget, tar, and sha256sum or shasum. One update runs at a time for an install: a second is E_BUSY, details.reason update_running. A host that does not answer is E_REMOTE_UNREACHABLE, details.phase update. A download, check or replacement that fails is E_IO with details.step (install, verify, swap, lock or receipt): before the two renames nothing was replaced.
--auto off and --auto on write the receipt's auto_update, and --status says whether the install updates itself (auto_update: on, or what turned it off) and gives the note a run in the background left (pending). SWARMOPS_AUTO_UPDATE=off turns automatic update off for the processes that have it; CI and a container turn it off unless that variable is on; root's install, and one in another user's directory, never update themselves. --background does what automatic update does: with automatic update on, it installs the latest release only when that carries the mark for the installed minor line (auto-update-from-<major>.<minor>, a file of the release), and leaves a note beside the binaries; a release without the mark is noted at its second sighting, and a request that fails changes nothing and is no error.
Where automatic update is on, a command that went well starts update --background once a day, after its envelope is out, and waits for nothing: its output and exit code do not change. The next such command whose stderr is a terminal prints the note, one line on stderr after its envelope, once. mcp, serve, auth git-credential, ws hook and update itself start no such run and print no note.
- Group
store- Since
0.12.0- Mutates
- no
- Identity required
- no
- MCP tool
- none
- Envelope op
update- Exit codes
- 02
- Errors
- E_INVALID_ARG
Syntax#
swarmops update [OPTIONS]Required arguments#
None.
Optional arguments#
The command also takes the global options.
Syntax: --check.
Look for the latest release and say what it is: install nothing.
Syntax: --auto <SWITCH>.
Turn this install's automatic update on or off, in its receipt. Reaches no network. Values: on: Automatic update on; off: Automatic update off.
Syntax: --status.
Say whether this install updates itself, and what decided so. Reaches no network.
Syntax: --background.
Do what automatic update does: install the latest release only if it is marked for the installed line, and leave a note of what was done.
Examples#
swarmops update --statusShow 7 more lines
},Exit code 0. Recorded by the CLI tests. A name in square brackets, such as [tmp] or [c1], stands for what differs from run to run: the test's temporary directory, an id, a time.
Details#
update replaces the program itself, swarmops and so, with the latest release, and holds the
switch of automatic update. It opens no store: --repo and --as are read and not used, and
the envelope has no meta.repo. It never changes a store, and never runs
upgrade, which is the store's command and yours alone to run. It
has no MCP tool: a call would replace the program the server runs from.
The forms are one at a time: no flag installs, --check looks, --auto on|off and --status
are the switch (Automatic update's switch), and --background is
what automatic update runs (In the background) after a command
(After a command).
What it updates#
Only an install the installer made, in a build a release holds:
| The binaries came from | update |
|---|---|
The installer (install.sh) | Works. The installer leaves a receipt beside them, .swarmops-receipt. |
A .deb or .rpm, or a server image | E_INVALID_ARG, details.reason no_receipt, with details.dir. Install the next release's package. |
| An archive unpacked by hand, or an installer older than the receipt | no_receipt. Running the installer once, with --dir naming the directory, leaves a receipt. |
A clone (cargo install, cargo build) | not_a_release_build, whatever is beside them. Build the newer source. |
The install is the directory the running program's own file is in, with every link on the way
followed: so reached through a link in another directory updates the directory it points
into. A release's build that cannot find its own file is E_INVALID_ARG (details.reason
exe_unknown). A file by the receipt's name that is no receipt (not TOML, without
receipt = 1, without auto_update = true or false, or over 64 KiB) is refused by every
form (details.reason receipt, details.path) and never written over.
What an update does#
- The latest release. One HEAD request to
https://github.com/KeiaiLab/SwarmOps/releases/latest, which GitHub answers with a redirect to the latest release's page. The redirect is not followed. Its address must be exactlyhttps://github.com/KeiaiLab/SwarmOps/releases/tag/v<X.Y.Z>, three plain numbers: anything else, a pre-release's page among it, isE_REMOTE_UNREACHABLE. GitHub'slatestnever names a pre-release. - What is installed.
swarmops --versionandso --versionin the install directory; the lower of the two counts, so that an update stopped between the two names is finished by the next one. A name that is missing, or answers as another program, has no version, and then the install has none:currentis the running program's own. - Only a newer release. A latest release that is not strictly newer installs nothing:
updatedisfalse, exit 0. A pre-release is older than its release. Nothing ever installs a version older than the program that runs, whatever the two names answer: GitHub'slatestcan name an older release, after one was deleted or when a patch of an older line was published last. To go back, or to pin a version, run the installer with--version, which also turns automatic update off. Where the install has no version, a latest release that is the running program's own version or a newer one is installed, and writes both names, as the installer does: a program of your own namedsoin that directory is replaced. Only anupdateyou run does that; the run in the background installs nothing there. - Download, check, unpack. The installer built into the program runs under
/bin/shfor that release, into.swarmops-update.dbeside the binaries: it downloads the archive for this host and the release'sSHA256SUMS, checks the one against the other, and unpacks the two binaries. It is the installer this build's source holds, not one fetched for the occasion, and it refuses what the installer refuses: a host without a build in the release, a glibc older than the release needs, a checksum that does not match. - Run before replacing. Each staged binary is run once and must print exactly
swarmops <X.Y.Z>, the release's line. One that does not start on this host, or is another version, replaces nothing. - Replace. The staged
swarmopsis renamed over the installed one, thenso, and the directory is flushed. Each name is whole at every moment. Between the two renamesswarmopsis new andsoold; step 2 repairs an update that stopped there.
previous is the version replaced and current the one installed when the command ended;
latest and notes are the latest release and its page. A process that already runs keeps the
program it started with: a swarmops mcp server serves with the old one until it is restarted.
One update runs at a time for an install. A second update is E_BUSY (details.reason
update_running, exit 4): run it again when the first has ended. The lock is
.swarmops-update.lock beside the binaries, held from before the latest release is asked for
until the binaries are replaced, and freed by the system however the process ends. The installer
itself takes no lock: do not run it into the same directory while an update runs.
What it runs, and what that sends#
SwarmOps has no network code of its own.
- curl, for the latest release. One run of the curl
SWARMOPS_CURLnames by an absolute path, else the firstcurlonPATH, asauth loginruns it: the request on its stdin, a cleared environment but forPATH, the proxy variables and the certificate variables, https only, TLS 1.2 or later, no redirect followed. A host without curl isE_INVALID_ARG(details.reasoncurl_missing), also where the installer itself would have used wget. The request carries no token; GitHub sees your address, the repository's path, and the headerUser-Agent: swarmops-update, which names no version. - The installer, for the release.
/bin/shand the tools the installer needs onPATH: curl or wget, tar, and sha256sum or shasum. It getsPATH,HOME,TMPDIR, the proxy variables and the certificate variables, and no other variable:SWARMOPS_VERSION,SWARMOPS_INSTALL_DIRand the installer's test seams do not reach it. It downloads fromhttps://github.com/KeiaiLab/SwarmOps/releases/download/, following GitHub's redirects, with its downloader's own headers. What it prints is read and dropped; its last line is in the error when it fails. It is stopped after ten minutes.
What this is checked against: HTTPS to GitHub, and the release's own SHA256SUMS, which comes
from the same place as the archive. No signature is checked, as none is by the installer. A
release older than what is installed is never taken, so an old release cannot be replayed; a
host that is shown no newer release at all cannot tell. These requests have been tested against
stand-ins on the testing host, and not yet run against GitHub.
What can fail#
| What happened | Error | details |
|---|---|---|
| The build is no release's | E_INVALID_ARG | reason not_a_release_build |
| No receipt is beside the binaries | E_INVALID_ARG | reason no_receipt, dir |
| The receipt is none this build reads | E_INVALID_ARG | reason receipt, path |
| The program cannot find its own file | E_INVALID_ARG | reason exe_unknown |
| There is no curl | E_INVALID_ARG | reason curl_missing |
| Another update runs | E_BUSY | reason update_running |
| curl reached no answer | E_REMOTE_UNREACHABLE | phase update, host, cause, curl_exit |
| The answer names no release | E_REMOTE_UNREACHABLE | phase update, host, http_status when it had one |
| The lock file cannot be made | E_IO | step lock, path |
| The installer failed, or was stopped | E_IO | step install, installer_exit and installer (its last line), or deadline_s |
| A staged binary is not the release | E_IO | step verify, expected, found |
| A binary could not be renamed into place | E_IO | step swap, path |
| The receipt could not be read or written | E_IO | step receipt, path |
Exit 2 for E_INVALID_ARG, 4 for E_BUSY and E_REMOTE_UNREACHABLE, which can be run again,
and 1 for E_IO. Up to and including verify, nothing was replaced, and the message says so.
A swap that failed on so has replaced swarmops, and its message starts by saying so: run
update again.
Automatic update's switch#
--status reaches no network and says whether this install updates itself after a command.
auto_update is on, or the first of these that holds:
auto_update | What decided |
|---|---|
off_source_build | The build is no release's. |
off_no_receipt | No receipt is beside the binaries. |
off | The receipt says auto_update = false: --auto off wrote it, or the installer did (for --no-auto-update, a named --version, or root). |
off_env | SWARMOPS_AUTO_UPDATE is off, or holds anything but on and off. Empty counts as unset. |
off_ci | CI is set to anything but the empty string, 0 or false, and SWARMOPS_AUTO_UPDATE is not on. |
off_container | /.dockerenv or /run/.containerenv exists, and SWARMOPS_AUTO_UPDATE is not on. |
off_owner | The caller is root, or the install directory belongs to another user. |
SWARMOPS_AUTO_UPDATE=on only cancels the CI and container rules. No store, remote, workspace
file or MCP request reads or sets any of this.
--auto off and --auto on write the receipt's auto_update, through a temporary file renamed
over it, mode 0644, and reach no network. Keys this build does not know are kept; comments are
not. --auto on needs what update needs, so it never makes a receipt for a package's install;
--auto off where there is no receipt changes nothing and is no error. The result's
auto_update is the answer after the write: --auto on as root still says off_owner.
None of the rules stops an update you run yourself, which needs only a release's build and a
receipt.
dir is the install directory, there only when a receipt was found. pending is the note a
background run left: its kind (updated, available or
failed), the release it is about (to) and, for updated, the version replaced (from).
--status reads the note and leaves it.
In the background#
update --background does what automatic update does, in one run: a command starts it
(After a command), and it runs when you run it. Unless auto_update is on
it does nothing. Otherwise it takes the lock, waiting half a second at most (another update
running: nothing), and asks for the latest release as above. Where one of the two names is
missing or answers as another program, it stops there: it replaces no program whose version it
cannot tell. When the release is newer than what is installed, and no older than the program
that runs:
- A release remembered as failed is left alone, until an
updateyou run goes well. - One more HEAD request asks whether the release holds the file
auto-update-from-<major>.<minor>, named for the minor line installed: the release's mark that a build of that line may install it unasked. GitHub sees the minor line in that address. - 302, the redirect to a file the release holds: the release is installed as above, with
three minutes for the installer. The note is
updated <from> <to>. A release that was downloaded and refused, by the installer (a checksum that does not match, a host it has no build for) or because a staged binary is not the release, is remembered as failed at once, with the notefailed <to> <the installer's last line>. One that could not be downloaded, was stopped at the three minutes, or could not be renamed into place may go well another day, and so may one whose installer ended with no exit code or without a line of its own, which named nothing it refused: the try is counted and nothing is said, the next day's check tries again, and the third try that fails is remembered as the failure, with its note. - 404, no such file: the release is announced, not installed. The first time a release is
seen unmarked, only that is remembered; the note
available <to>is written the next time it is still unmarked, and once. A release is the latest before its marks are uploaded. - Anything else, or no answer: nothing is written, and the next run asks again.
It prints its envelope like every command, exit 0 unless the receipt is refused, with
updated and pending saying what it did; a request that fails changes nothing and is no
error. Only the latest release is ever looked at: an install on an older line installs nothing
automatically while the latest release carries no mark for that line.
After a command#
Where auto_update is on, every command that went well is followed by automatic update, once
its envelope is out. The command's envelope, exit code and meta.elapsed_ms are what they are
without it, and it waits for nothing.
- The note. If the command's stderr is a terminal and a background run left a note, the
command removes the note and prints it, one line on stderr after the envelope. Of several
commands at once, one prints it. A command whose stderr is no terminal (a script, an agent's
harness,
2>&1into a pipe) prints nothing and leaves the note:--statusgives it aspending. - The check, once a day. The lock file's modification time is when a check was last
claimed. Less than 24 hours ago, the command is done. Otherwise it claims the check (it
locks the file without waiting, looks at the time again, and sets it to now) and starts
update --background. Of several commands at once, one claims it. The claim comes before any request, so a host without a network asks once a day and says nothing. A time in the future, as a clock set back leaves, counts as long ago. - The run it starts is this program again, detached: a process group of its own,
/for its directory, no stdin, stdout or stderr, and without the descriptors 3 to 9 the command inherited (it is started through/bin/sh, which closes them), so that it does not hold a lock or a pipe of the caller's for as long as a download takes. A descriptor numbered 10 or more that the caller passed down without close-on-exec stays open in it. It has the command's environment.
The notes say what happened, and tell nobody to run anything:
swarmops: updated from 0.12.0 to 0.13.0. Notes: https://github.com/KeiaiLab/SwarmOps/releases/tag/v0.13.0. Running mcp servers keep 0.12.0 until restarted.
swarmops: 0.13.0 is released and was not installed automatically. Notes: https://github.com/KeiaiLab/SwarmOps/releases/tag/v0.13.0.
swarmops: 0.13.0 could not be installed automatically: <the installer's last line>.Their wording is no contract; pending is. A note is printed only where auto_update is on
for the command that would print it.
Automatic update follows no run that is not a command that went well: not --help or
--version, not a line that is refused, not a command that fails. And it follows none of
mcp, serve, serve --prepare, auth git-credential, ws hook and update itself: a host
that uses SwarmOps only through swarmops mcp never looks for a release and never prints a
note. A directory the caller cannot write is never claimed in, so nothing is started there.
The files beside the binaries#
| File | What it is |
|---|---|
.swarmops-receipt | The installer's receipt: receipt = 1 and auto_update = true or false. |
.swarmops-update.lock | The lock, and what the background run remembers: a line each for the release last seen unmarked, announced, tried (with how many times) and failed. Its modification time is when a check was last claimed. |
.swarmops-update.note | One line: the note a background run left, which --status gives as pending. |
.swarmops-update.d | The staging directory, there only while an update runs; one left behind is removed by the next. |
The installer's --uninstall removes all four. See
Install for the installer.
Return information#
result is a UpdateOut (swarmops schema UpdateOut prints its JSON Schema).
| Field | Type | Required | Description |
|---|---|---|---|
auto_update | AutoUpdate | yes | Whether the install updates itself after a command, and if not, why. |
current | string | yes | The installed version when the command ended. For the forms that ask no binary for its version (--status, --auto, a --background that stops before it looks), and where one of the two names has none, the running program's own. |
dir | string or null | no | The directory the binaries are installed in, a path on the caller's host. Omitted when no receipt is beside them. |
latest | string or null | no | The latest release. Omitted when the command did not look for it. |
notes | string or null | no | The page of the latest release's notes. Omitted when the command did not look for it. |
pending | UpdatePending or null | no | The note an automatic update left that no command has printed yet. Omitted when there is none. |
previous | string or null | no | The version this run replaced. Omitted when nothing was replaced. |
updated | boolean | yes | Whether this run replaced the program. False when the latest release is not newer than what is installed, and for the forms of the command that install nothing. |
Envelope op: update.
Exit codes:
0: Success.2: The request or the command line is malformed.
Errors#
- E_INVALID_ARG (exit 2): A malformed argument or request, including a command-line usage error.
Any command that opens a store may also fail with a store error, such as E_NOT_A_REPO, E_IO or E_STORE_CORRUPT; a command line the grammar refuses is E_INVALID_ARG (exit 2).