Skip to content

feat: surface Coder access URL in terminals via /tmp/coder-access-url - #62

Merged
phorcys420 merged 5 commits into
mainfrom
phorcys/motd-access-url-tmpfile
Aug 24, 2026
Merged

feat: surface Coder access URL in terminals via /tmp/coder-access-url#62
phorcys420 merged 5 commits into
mainfrom
phorcys/motd-access-url-tmpfile

Conversation

@phorcys420

Copy link
Copy Markdown
Member

Closes #61.

What

Surface the live Coder access URL (*.try.coder.app tunnel) in any terminal on login, not just PAM sessions.

Previously coder-redirect.service wrote the URL to /etc/motd, which only shows on SSH/console logins via pam_motd — a local desktop terminal never saw it.

How

  • coder-redirect.service now caches the discovered tunnel URL to /tmp/coder-access-url (chmod 0644) instead of writing /etc/motd. It rm -fs the file at the top of ExecStart, so the stale URL is cleared on every boot and on every service restart until the live URL is rediscovered. Both the cleanup and the write are best-effort (|| true) so a /tmp hiccup can't trip set -euo pipefail and restart-loop the redirect.
  • New environment.interactiveShellInit prints an Access URL / Local / Redirect banner by reading that file — no network access. An exported CODER_ACCESS_URL_SHOWN guard keeps nested shells from reprinting it within a session. This covers local GNOME terminals, console TTYs, and SSH from one place.
  • Docs updated (README.md, hosts/incus-vm/README.md, install.sh) to point at the terminal banner / /tmp/coder-access-url instead of /etc/motd.

The large configuration.nix diff is mostly nixfmt renormalizing the coder-redirect script: removing the heredoc left the block uniformly indented, so the formatter re-based it to the canonical column.

Verification

Ran in a workspace with the repo's own toolchain (nix fmt = treefmt: nixfmt/statix/deadnix/shfmt/shellcheck):

  • nix fmt idempotent (0 changed)
  • shellcheck install.sh clean
  • nixosConfigurations._appliance-iso evaluates; built coder-redirect script and rendered interactiveShellInit inspected — escaping and || true guards land correctly
  • Ran the banner snippet: prints once, guard suppresses the repeat

Not build/boot-tested on real hardware (needs a box).

Implementation notes / decisions
  • Dropped /etc/motd entirely rather than keeping it alongside the banner. Keeping both would double-print on SSH/console (pam_motd + shell banner); consolidating on the shell banner gives one source of truth that also works in desktop terminals. Console TTY and SSH still get the URL because their login shell sources the init.
  • interactiveShellInit vs loginShellInit: GNOME Terminal opens a non-login interactive shell by default, so loginShellInit/profile.d wouldn't fire there. interactiveShellInit covers it; the exported guard prevents subshell spam.
  • Hostname read at display time from /proc/sys/kernel/hostname (always present) to match the previous runtime hostname behavior rather than baking networking.hostName at eval time.
  • /tmp wipe: relying on tmpfs-on-boot isn't guaranteed here, so the explicit rm -f in ExecStart (which runs on every boot and restart) is what satisfies "wipes on boot or restart of coder-redirect".

🤖 Opened by Coder Agents on behalf of @phorcys420.

coder-redirect now caches the live *.try.coder.app tunnel URL to
/tmp/coder-access-url (cleared on every service (re)start) instead of
writing /etc/motd. A new environment.interactiveShellInit prints the URL
on interactive shells, so a local desktop terminal shows it too, not just
PAM logins. The banner only reads the file and never touches the network.
…cess (local)"

Instead of clearing /tmp/coder-access-url on coder-redirect (re)start, seed it
with $CODER_LOCAL so a terminal opened before the tunnel is up still shows a
reachable URL. Once the tunnel URL is known the file is upgraded to
"<access URL> (<local URL>)". The login banner now just prints the file, so
the local URL is no longer hardcoded in two places.
Introduce a coderPort let-binding (3000) that drives CODER_HTTP_ADDRESS and
every in-box URL targeting the server (coder-redirect CODER_LOCAL, agent URL,
bootstrap, reset, template sync, reaper, logstream) instead of hardcoding the
port at 14 sites.
…redirect

Replace the two inline printf/chmod writes to /tmp/coder-access-url with a
single write_accessUrl shell function; the seed and upgrade paths just call it.
@phorcys420
phorcys420 marked this pull request as ready for review August 24, 2026 20:21
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

📀 ISO build artifacts

Kind Arch Size Download
Installer aarch64 3.49 GB ⬇️ coder-box-installer-aarch64-linux.iso
Installer x86_64 3.67 GB ⬇️ coder-box-installer-x86_64-linux.iso

↻ Updated for caeb1f6 · run #123 · artifacts expire in ~1 day · sign in to GitHub to download.

…rl-tmpfile

# Conflicts:
#	README.md
#	configuration.nix
@phorcys420
phorcys420 merged commit c109326 into main Aug 24, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add instance URL to MOTD in terminal

1 participant