System control for odio: upgrades, components, DAC overlay and a local web UI.
Part of the odio project — documentation.
odioctl is the CLI and web UI for configuring an odio
node — upgrades, components and DAC selection today, and meant to grow with
the rest of the node's settings. It started as a rewrite of the odio-upgrade
script that used to ship inside odios.
A single static Go binary (stdlib only), packaged as per-arch .debs on
apt.odio.love.
# odios installs and wires it for you. By hand, on a system with the odio apt repo:
sudo apt install odioctlThe package ships (not auto-enabled — odios' installer enables them per user):
| File | Purpose |
|---|---|
/usr/lib/systemd/user/odio-check-upgrade.{service,timer} |
daily odioctl upgrade check |
/usr/lib/systemd/user/odio-upgrade.service |
sudo odioctl upgrade apply --progress (started by odio-api) |
/usr/lib/systemd/user/odioctl-web.socket |
port 8021, the LAN door |
/usr/lib/systemd/user/odioctl-web-proxy.socket |
$XDG_RUNTIME_DIR/odioctl-web.sock, the door odio-api's reverse proxy uses (see Behind odio-api) |
/usr/lib/systemd/user/odioctl-web.service |
odioctl web --systemd-only, started on the first connection to a socket; never enabled itself |
Enable one socket or both: the service serves those that run and never binds
anything itself, so a door odios leaves closed stays closed.
| /etc/sudoers.d/odioctl | NOPASSWD for the odioctl group: upgrade apply --progress, dac set <id> (one line per id), dac unset |
The postinst creates the odioctl system group and leaves it empty; odios adds
its target user. It is deliberately not the odio group, which carries
state.json access and holds the installing user too: a group that grants reads
must not also grant passwordless root.
It also owns where state.json and upgrades.json live, re-applied on every
install: /var/lib/odio 2770 root:odio and /var/cache/odio 2775 root:odio
(creating odio if odios has not yet). Purging the package removes the cache,
never /var/lib/odio: state.json is not something to regenerate.
odioctl upgrade check [--version TAG] [--state PATH] [--output PATH]
odioctl upgrade apply [--version V] [--state PATH] [--dry-run] [--force] [--reinstall] [--progress|--no-progress]
odioctl upgrade verify [--state PATH] [--expected-version TAG]
odioctl pwa-url
odioctl components [--state PATH] list [--json] | enable NAME | disable NAME
odioctl dac list [--json] | status [--json] | set ID [--dry-run] | unset
odioctl web [--bind 0.0.0.0] [--port 8021] [--socket PATH] [--systemd-only] [--odio-api URL] [--state PATH] [--config PATH]
odioctl state [--state PATH] record < run.json | show
odioctl motd [--state PATH]
Exit codes: check 0 up to date / 1 upgrades available / 2 error · apply 0
upgraded (or nothing to do) / 1 install.sh failed / 2 error · verify 0 valid /
1 invalid / 2 state.json missing · state show 0 shown / 1 refused / 3
state.json missing · state record 0 recorded / 1 write failed / 2 run refused.
Reads /var/lib/odio/state.json (written by odios after every run), compares it
with the published manifest (https://odio.love/manifest.json or the release
asset for --version), caches the result in /var/cache/odio/upgrades.json
(read by odio-api and odio-motd), and re-runs install.sh from the target
release with INSTALL_* derived from the state (opt-outs) and RUN_*=N for
roles whose version did not move (smart upgrade). A re-run never prompts, so
what install.sh asked at install comes back from the state too: AUDIOSERVER,
MPD_MUSIC_DIRECTORY, MPD_CONF_PATH (the last two only when recorded, else
install.sh's defaults). --reinstall re-runs every
role in full. apply follows the report check wrote: with none on disk there
is nothing to apply, unless --force or --version says otherwise. A custom
--state keeps upgrades.json next to it for every subcommand and for web.
Only the current state.json schema is accepted — pre-2026.5 installs are not
supported.
Targeting a pre-release. An odio installed from a PR build runs a release the
published manifest knows nothing about, so every role only that build ships
reads as "not in this release" and never goes pending. check --version pr-84,
or ODIOCTL_ODIOS_VERSION=pr-84 in /etc/default/odioctl (read by the daily
timer and by odioctl web, which refreshes upgrades.json on every toggle),
compares against that release instead. Only a tag is overridable, never a
URL: it is interpolated into a github.com/b0bbywan/odios release path, and
anything that could walk out of it is refused — including a tag read back from
upgrades.json, which is group-writable while apply curls that URL into bash
as root. check records the tag under target_tag because a pre-release names
itself by version (2026.7.0rc2-9-gcad916c) and is published under a tag
(pr-84); apply needs the latter.
state.json's schema belongs to odioctl; odios reports to it rather than writing the file itself.
recordis whatwrite_state.ymlcalls, as root, with what the run installed on stdin:odios,install_mode,target_user,audioserver(pulseaudio|pipewire),mpd_music_directory,mpd_conf_path(the effective paths,""when install.sh's default or detection applies; absolute, no quotes, backslashes or control characters, since install.sh splices them into its extra-vars run as root),roles(name → version),roles_excluded,features,features_excluded— every one of them and nothing else, so an odios newer than this odioctl is refused rather than half-recorded. odioctl appends the release torelease_history, drops the audio server that was not picked fromroles_excluded(not picking it is not declining it), and writes the file atomically, mode 0660 (the group comes from/var/lib/odio, 2770 root:odio). A state.json it cannot read is replaced, history restarting from this run.- name: Record state.json ansible.builtin.command: odioctl state record args: stdin: "{{ _odios_run | to_json }}" become: true
showprints state.json as odioctl reads it, forread_state.yml: what an earlier odios left out is filled in (noaudioserverispulseaudio). 3 means no state.json (a fresh install), 1 one odioctl refuses; 2 is not one of its answers but an odioctl that predatesstate show— the case of every odio upgrading from before it, sinceread_state.ymlruns before theupgraderole installs the new odioctl.
odio's login banner, what odios' branding role shipped as a shell script: the
release and, when check found one, the upgrade waiting with its per-role
detail (upgrades.json, read here instead of by a python3 spawned at every
login), then the PWA link and the warranty line. Always exits 0 — a login
shell is not the place to fail — and leaves out whatever it cannot read.
odios keeps only the hook, in the target user's ~/.profile:
case $- in
*i*) command -v odioctl >/dev/null && odioctl motd ;;
esacRoles (services) and features (plugins of a role) as recorded in state.json.
Disabling adds the name to roles_excluded/features_excluded (and drops it
from roles/features); enabling clears the exclusion so install.sh's own
default installs it on the next run. Nothing is installed or removed until
odioctl upgrade apply runs (--force to run it right away). A role the
release marks required in its catalog — common, upgrade, odio_api,
mpd and the audio server — is listed with its version but never offered
for disabling; the audio server odio does not run is not listed at all.
Names present in state.json are always accepted, even if newer than this
odioctl.
Owns one marked block, first in /boot/firmware/config.txt:
# BEGIN odioctl dac -- managed block, edit with `odioctl dac`
[all]
dtparam=audio=off
dtoverlay=hifiberry-dacplus-std
# END odioctl dac
First, because the file's own overlays have to come after it: vc4-kms-v3d
disables snd_bcm2835's legacy HDMI card, so an audio=on landing after that
overlay brings the dead card back — two "Built-in Audio Stereo", PulseAudio
picking the wrong one and hanging on vchi message timeout. Being first is
also what leaves dtparam= on the base DTB, no overlay being open yet.
Pre-existing top-level audio lines — a dtparam=audio= or an overlay the
catalog lists — are commented out with an #odioctl-disabled: prefix and
restored by dac unset. An overlay the catalog does not list is left alone:
whether a name is audio is not something to guess at. A one-time backup is
kept as config.txt.odioctl.bak; a reboot is required (/run/odioctl/reboot-required
flags it until then). set/unset need root — the web UI calls them through
sudo -n, and the sudoers file lists every catalog id explicitly, so no other
argument (in particular --config) can go through sudo.
A stdlib net/http server on port 8021 serving one server-rendered page —
HTML forms over htmx (the same htmx and SSE extension as odio-api's
dashboard), no JSON API: a components table where one icon per row is both the
state and its toggle — the action shows on hover, a lock stands for a required
role — and a DAC picker (select + Apply, Reset to drop the odioctl block, then a
Reboot button on the banner the change leaves). Actions are
POST /components, POST /dac, POST /dac/unset, POST /reboot; the page answers with
a message or error banner and every section follows odio live over
GET /events. Every form carries a per-process token, so a cross-site page
cannot drive odio. There
is no authentication (same LAN trust model as odio-api); use --bind 127.0.0.1
to keep it local. Runs as the odios target user; state.json is edited
directly (needs /var/lib/odio group-writable by odio, see below),
config.txt through sudo -n odioctl dac … (needs that user in the odioctl
group).
The logo links to odio-ui, odio-api's dashboard: /ui behind odio-api's
proxy (the page is on its origin), else http://<host>:<port>/ui, <host>
being the name the browser used and <port> --odio-api's. No link without
odio-api.
Upgrades go through odio-api (≥ the release whose run follows the unit
whoever started it), at --odio-api (or ODIOCTL_ODIO_API in
/etc/default/odioctl), http://127.0.0.1:8018 by default:
"Apply now" is its POST /upgrade/start, and the Upgrade card is its run,
followed from startup on its GET /events (from GET /upgrade on each
connection) — running with the percent and step odios' progress callback
streams to it, then done or failed, with what failed when its playbook said. When odio-api does not answer, the card says so and offers no
Apply button; ssh + sudo odioctl upgrade apply stays the way round.
odioctl can be served by a reverse proxy, odio-api's /ui/admin/ (odio-api ≥
0.17.4) being the one it is meant for: beside port 8021 while odios moves over,
instead of it once done.
- The door.
odioctl-web-proxy.socketlistens on$XDG_RUNTIME_DIR/odioctl-web.sock, mode 0600: only the target user, whom odio-api runs as, can connect. Without systemd,--socket PATHdoes the same. - What odioctl reads from the proxy, on that socket only (never on 8021,
where anyone could forge them):
X-Forwarded-Prefixbecomes the page's<base href>(every URL of the page is relative to it),X-Forwarded-Hostthe host of an action's OAuth callback,X-Forwarded-Forthe address in the log. - What the proxy must do: strip the prefix from the path,
SetXForwarded()(Go'shttputil.ReverseProxy), set — not add —X-Forwarded-Prefix, sinceRewritedoes not drop a client's own, and pass/eventsthrough unbuffered (SSE;ReverseProxyflushestext/event-streamby itself).
Switching an odio over (odios' upgrade role). Two rules from systemd
drive the order in live mode: it refuses to start a socket under a service
that is already running, and a running service keeps the fd of a socket
stopped under it (the port stays open). So the service is stopped first, and
the next connection starts it again with exactly the doors that run — on the
new binary too, which makes the stop a replacement for the "Restart
odioctl-web" handler. Image mode needs none of it: sockets bind at boot,
before the service.
- Both doors, while odio-api and odio-ui catch up. Require the odioctl
release that ships
odioctl-web-proxy.socket(upgrade_odioctl_apt_version), enable it likeodioctl-web.socket(wanted_by: sockets.target), then:Point odio-api at the socket:systemctl --user stop odioctl-web.service systemctl --user start odioctl-web-proxy.socket
api.ui.adminSocket: /run/user/<uid>/odioctl-web.sockin itsconfig.yaml.j2, next toapi.ui.admin: ":8021". Its admin link goes through/ui/admin/while the socket file exists — from the moment the unit runs, without wakingodioctl web— and falls back toadminotherwise. - The proxy only. Swap
odioctl-web.socketforodioctl-web-proxy.socketinupgrade_servicesand the enable task, and on odios already switched:odioctl is then reachable through odio-api only;systemctl --user stop odioctl-web.service systemctl --user disable --now odioctl-web.socket systemctl --user enable --now odioctl-web-proxy.socketssh+odioctl upgrade applystays the way back if odio-api is what broke.
make lint test
go run . web --bind 127.0.0.1 --state /tmp/state.json --config /tmp/config.txt
# the proxy door: --socket, then speak to it as odio-api would
go run . web --bind 127.0.0.1 --socket /tmp/odioctl-web.sock --state /tmp/state.json
curl --unix-socket /tmp/odioctl-web.sock -H 'X-Forwarded-Prefix: /ui/admin' http://odio/
make deb # cross-compiles amd64/armhf/arm64 and packages via nfpmdata/sudoers/odioctl is generated from the DAC catalog: make sudoers
(= go generate ./dac).
BSD 2-Clause — see LICENSE.
