Skip to content

Commit f9319e4

Browse files
ralyodioclaude
andauthored
W3BS OS: dev tools + root-w3bs-os during the install, clear encryption choice, GUI fonts, w3bs trust fix (#209)
Asked for: pnpm and bun via mise, curl, wget, `pnpm i -g @profullstack/readm3`, and the cli-tools root-*.sh (Alpine: root-w3bs-os.sh) run during the install, plus an obvious way to skip disk encryption. Found on VirtualBox: the install log was black on black. - Every install (desktop and server): curl wget mise nodejs npm; per user mise use -g bun npm:pnpm (npm backend: no GitHub API rate limit; Node from Alpine since mise's is glibc), pnpm i -g @profullstack/readm3; /etc/profile.d/w3bs-dev.sh puts shims and PNPM_HOME on PATH. - root-w3bs-os via its pinned, sha256-checked installer, run in the target for the users (--groups wheel --refresh); /etc/local.d/w3bs-first-boot.start re-runs it once at first boot to enable the services a chroot cannot start. - GUI: the installer's packages stay in the live world (removing them let apk delete the fonts mid-install: blank log and labels); they are dropped from the target's world instead. Disk page: "Encrypt the disk (recommended)" / "Do not encrypt" cards. - w3bs-core: an empty or unparseable saved root.json fell back to nothing and every w3bs install failed ("Failed to parse trusted root metadata: EOF"), so moshcode/hqterm never installed; use the pinned initial root instead. Installer also deletes 0-byte root.json and makes the motd cache readable (login printed "Permission denied"). Tested: QEMU server install -> curl wget mise node bun pnpm readm3 0.20.0 threatcrush tmux ufw oh-my-zsh present, first boot completed; VirtualBox reproduced the blank log (Pango "file not found"); cargo test -p w3bs-core 24 passed. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 4bb534d commit f9319e4

5 files changed

Lines changed: 110 additions & 11 deletions

File tree

‎os/iso/README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ installed system do not boot with Secure Boot on.
2525
| Desktop | Hyprland with greetd + tuigreet (below); the installer shows a numbered menu | `--desktop hyprland\|plasma\|gnome\|xfce\|none` |
2626
| W3BS | `w3bs` and `w3bs-desktop` (musl builds) in `/usr/local/bin`; the W3BS repository (`https://w3bs.org/repo/`, pinned to `registry/FINGERPRINT`) is added for each user at first login | |
2727
| Browsers | desktop installs: Firefox (SUPER+B) and [TronBrowser](https://tronbrowser.dev) (SUPER+SHIFT+B) for every user; TronBrowser runs on the Flathub Ungoogled Chromium, since its own engine is a glibc build | |
28+
| Dev tools | every install: curl, wget, Node (Alpine, musl), mise managing bun and pnpm per user (`mise use -g bun npm:pnpm`), and `pnpm i -g @profullstack/readm3`; on PATH via /etc/profile.d/w3bs-dev.sh | |
29+
| Box setup | every install runs [root-w3bs-os](https://github.com/profullstack/cli-tools/blob/master/root-w3bs-os.sh) (cli-tools, pinned + sha256-checked) for the users: oh-my-zsh, oh-my-tmux, threatcrush, moshcode, hqterm, ufw, swap/zram/earlyoom, per-user Caddy; services it cannot start in the install chroot are finished by a one-time run at first boot (/var/log/w3bs-first-boot.log) | |
30+
| Encryption choice | text: the yes/no question or `--no-encrypt`; graphical: "Encrypt the disk" or "Do not encrypt" on the disk page | |
2831
| Agentic Desktop Layer | broker and tray autostart in the desktop session; agent access is **off** until the user turns it on (never `--enabled-by-default`) | |
2932

3033
The installer shows a review screen (exact disk, size, model, current partitions, every

‎os/iso/overlay/usr/local/sbin/w3bs-os-install‎

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,8 @@ $(lsblk -no NAME,SIZE,FSTYPE,LABEL "$DISK" 2>/dev/null | sed 's/^/
464464
SSH $( [ -n "$SSH" ] && echo "sshd on: keys only, no password logins" || echo "off")
465465
Desktop $DESKTOP$( case "$DESKTOP" in plasma) echo " (KDE Plasma, SDDM)" ;; hyprland) echo " (Hyprland, greetd + tuigreet)" ;; none) echo " (server install: command line only)" ;; esac )
466466
W3BS w3bs CLI and w3bs-desktop in /usr/local/bin; W3BS repo added at first login
467+
Dev tools curl, wget, mise (bun, pnpm), Node, readm3 (pnpm i -g @profullstack/readm3)
468+
Box setup root-w3bs-os (cli-tools): oh-my-zsh, tmux, moshcode, threatcrush, hqterm, ufw, zram
467469
Browsers $( [ "$DESKTOP" = none ] && echo "none (server install)" || echo "Firefox and TronBrowser (tronbrowser.dev, Flathub Ungoogled Chromium engine)" )
468470
Agent access Agentic Desktop Layer installed, agent access OFF until you turn it on
469471
Web server Caddy, enabled, no sites (add them in /etc/caddy/sites/)
@@ -587,6 +589,13 @@ awk '$2 ~ /^\/boot/ { print $1, $2, $3 }' "$TARGET/etc/fstab" | sort -k2 | while
587589
echo "mounted $dev on $mp" >>"$LOG"
588590
done || fail "cannot mount the boot partition"
589591
for m in dev proc sys; do mount --bind "/$m" "$TARGET/$m" || fail "cannot bind /$m"; done
592+
# setup-disk installs the live system's world on the target, which includes the graphical
593+
# installer's own packages (GTK, cage, eudev): drop them from the target's world, and the
594+
# next apk run there removes whatever nothing else needs.
595+
if [ -r /run/w3bs-os-gui-pkgs ]; then
596+
for p in $(cat /run/w3bs-os-gui-pkgs); do sed -i "/^$p\$/d" "$TARGET/etc/apk/world"; done
597+
log "dropped the graphical installer's packages from the target world"
598+
fi
590599
mountpoint -q "$TARGET/dev/pts" || mount --bind /dev/pts "$TARGET/dev/pts" 2>/dev/null
591600
cp /etc/resolv.conf "$TARGET/etc/resolv.conf" 2>/dev/null
592601
in_target() { chroot "$TARGET" /usr/bin/env -i PATH=/usr/sbin:/usr/bin:/sbin:/bin HOME=/root TERM="${TERM:-linux}" "$@"; }
@@ -787,6 +796,76 @@ EOF
787796
fi
788797

789798
# --- W3BS -------------------------------------------------------------------------------
799+
# --- developer tools (every install: desktop and server) --------------------------------
800+
# curl and wget; mise manages bun and pnpm per user (pnpm through mise's npm backend, so no
801+
# GitHub API rate limit); Node is Alpine's own musl build (mise's Node downloads are glibc);
802+
# then pnpm i -g @profullstack/readm3. Per-user tool failures are warnings, not fatal.
803+
step "Installing developer tools (curl, wget, mise, Node, bun, pnpm, readm3)"
804+
in_target apk add --no-progress curl wget mise nodejs npm >>"$LOG" 2>&1 || fail "cannot install curl, wget, mise and Node"
805+
mkdir -p "$TARGET/etc/profile.d"
806+
cat >"$TARGET/etc/profile.d/w3bs-dev.sh" <<'EOF' || fail "cannot write /etc/profile.d/w3bs-dev.sh"
807+
# W3BS OS: mise-managed tools (bun, pnpm) and pnpm global commands (readm3) on PATH.
808+
export PNPM_HOME="$HOME/.local/share/pnpm"
809+
case ":$PATH:" in *":$HOME/.local/share/mise/shims:"*) ;; *) PATH="$HOME/.local/share/mise/shims:$PATH" ;; esac
810+
case ":$PATH:" in *":$PNPM_HOME:"*) ;; *) PATH="$PNPM_HOME:$PATH" ;; esac
811+
export PATH
812+
EOF
813+
chmod 0644 "$TARGET/etc/profile.d/w3bs-dev.sh"
814+
for u in $USERS; do
815+
if in_target su - "$u" -s /bin/sh -c '
816+
set -e
817+
export MISE_YES=1 PNPM_HOME="$HOME/.local/share/pnpm"
818+
export PATH="$PNPM_HOME:$HOME/.local/share/mise/shims:$PATH"
819+
mise use -g bun@latest npm:pnpm@latest
820+
pnpm config set global-bin-dir "$PNPM_HOME"
821+
pnpm config set global-dir "$HOME/.local/share/pnpm/global"
822+
pnpm i -g @profullstack/readm3
823+
bun --version; pnpm --version; readm3 --version' >>"$LOG" 2>&1; then
824+
log "bun, pnpm and readm3 installed for $u"
825+
else
826+
say "warning: could not install bun/pnpm/readm3 for $u (see $LOG); later run: mise use -g bun npm:pnpm && pnpm i -g @profullstack/readm3"
827+
fi
828+
done
829+
830+
# --- root-w3bs-os (cli-tools): the W3BS OS box setup, during the install ------------------
831+
# Accounts, base packages, dotfiles, oh-my-zsh/oh-my-tmux, mise, moshcode, threatcrush,
832+
# hqterm, ssh-agent, motd, per-user Caddy, ufw, swap/zram/earlyoom and confinement. Installed
833+
# through its pinned, sha256-checked installer, then run non-interactively in the target. In
834+
# the chroot no init is running, so it sets up everything but services; a one-shot at first
835+
# boot (/etc/local.d/w3bs-first-boot.start) re-runs it to enable and start those.
836+
step "Running root-w3bs-os (shell, tools, firewall, Caddy and account setup)"
837+
ROOT_W3BS_INSTALL=https://raw.githubusercontent.com/profullstack/cli-tools/master/install-root-w3bs-os.sh
838+
if in_target apk add --no-progress bash >>"$LOG" 2>&1 \
839+
&& in_target sh -c "curl -fsSL $ROOT_W3BS_INSTALL | sh" >>"$LOG" 2>&1 \
840+
&& [ -x "$TARGET/usr/local/sbin/root-w3bs-os" ]; then
841+
# shellcheck disable=SC2086
842+
if in_target /usr/local/sbin/root-w3bs-os $USERS --groups wheel --refresh </dev/null >>"$LOG" 2>&1; then
843+
log "root-w3bs-os ran for $USERS"
844+
else
845+
say "warning: root-w3bs-os reported errors (see $LOG); it runs again at first boot"
846+
fi
847+
# A cut-short TUF write left a 0-byte root.json, and w3bs then failed every install ("Failed
848+
# to parse trusted root metadata"); drop it so the pinned initial root is used. The motd
849+
# cache it writes as root must be readable by the login shells that print it.
850+
find "$TARGET/root" "$TARGET/home" -path '*/.local/share/w3bs/trust/*' -name root.json -size 0 -delete 2>/dev/null
851+
[ -f "$TARGET/var/cache/profullstack-motd" ] && chmod 0644 "$TARGET/var/cache/profullstack-motd"
852+
mkdir -p "$TARGET/etc/local.d"
853+
cat >"$TARGET/etc/local.d/w3bs-first-boot.start" <<'EOF' || fail "cannot write the first-boot script"
854+
#!/bin/sh
855+
# W3BS OS first boot: finish root-w3bs-os now that OpenRC runs (enable and start ufw,
856+
# earlyoom, Caddy, ssh-agent ...), once, in the background. Log: /var/log/w3bs-first-boot.log
857+
[ -e /etc/w3bs-os/first-boot-done ] && exit 0
858+
(
859+
for i in $(seq 1 60); do ping -c1 -W2 dl-cdn.alpinelinux.org >/dev/null 2>&1 && break; sleep 5; done
860+
/usr/local/sbin/root-w3bs-os --refresh </dev/null && touch /etc/w3bs-os/first-boot-done
861+
) >>/var/log/w3bs-first-boot.log 2>&1 &
862+
EOF
863+
chmod 0755 "$TARGET/etc/local.d/w3bs-first-boot.start"
864+
in_target rc-update add local default >>"$LOG" 2>&1 || fail "cannot enable the first-boot script"
865+
else
866+
say "warning: could not install root-w3bs-os (see $LOG); later: w3bs install profullstack.com/root-w3bs-os"
867+
fi
868+
790869
step "Installing Caddy (the default web server; no sites yet)"
791870
in_target apk add --no-progress caddy >>"$LOG" 2>&1 || fail "cannot install caddy"
792871
mkdir -p "$TARGET/etc/caddy/sites"
@@ -894,6 +973,7 @@ if [ "$BOOTMODE" = UEFI ]; then
894973
[ -n "$(find "$TARGET/boot" -maxdepth 4 -ipath '*/efi/*' -iname '*.efi' 2>/dev/null)" ] || fail "no EFI bootloader was installed"
895974
fi
896975
grep -qx ID=w3bs-os "$TARGET/etc/w3bs-os-release" || fail "/etc/w3bs-os-release is missing"
976+
for c in curl wget mise node npm; do in_target sh -c "command -v $c" >/dev/null 2>&1 || fail "$c is not installed"; done
897977
[ -L "$TARGET/etc/runlevels/default/caddy" ] || fail "caddy is not enabled"
898978
[ -z "$SSH" ] || [ -L "$TARGET/etc/runlevels/default/sshd" ] || fail "sshd is not enabled"
899979
ls "$TARGET"/boot/vmlinuz-* >/dev/null 2>&1 || fail "no kernel in /boot"

‎os/iso/overlay/usr/local/sbin/w3bs-os-install-gui‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ if ! command -v cage >/dev/null 2>&1 || ! command -v seatd-launch >/dev/null 2>&
3333
# shellcheck disable=SC2086
3434
apk add $PKGS >>"$LOG" 2>&1
3535
fi || { say "The graphical installer could not be loaded (see $LOG)."; exit 3; }
36-
# Keep them out of /etc/apk/world: setup-disk installs the live world on the target,
37-
# and the installed system has no use for the installer's GTK, cage or eudev.
38-
for p in $PKGS; do sed -i "/^$p\$/d" /etc/apk/world; done
36+
# They must stay in the live /etc/apk/world: setup-alpine runs apk in the live system
37+
# during the install, and apk deletes whatever the world no longer lists (the fonts went
38+
# first and the GUI drew blank text). w3bs-os-install drops them from the target's world.
39+
echo "$PKGS" >/run/w3bs-os-gui-pkgs
3940
fi
4041

4142
# libinput (cage) finds keyboards and mice through udev; the live system runs mdev.

‎os/iso/overlay/usr/share/w3bs-os/installer-gui.py‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,21 @@ def page_disk(self):
267267
first = first or b
268268
self.disk_btns.append((dev, size, b))
269269
box.append(b)
270-
self.encrypt = Gtk.Switch(active=True, halign=Gtk.Align.START)
270+
box.append(label("Disk encryption", "card-title"))
271+
# self.encrypt is the "Encrypt" card: get_active() is the choice.
272+
self.encrypt = self.card(None, "Encrypt the disk (recommended)",
273+
"LUKS2. A passphrase is asked at every boot; if you lose it, the data cannot be recovered.", True)
274+
self.no_encrypt = self.card(self.encrypt, "Do not encrypt",
275+
"Boots straight to the login screen. For VMs, test machines and servers with a web console.")
276+
row = Gtk.Box(spacing=16, homogeneous=True)
277+
row.append(self.encrypt)
278+
row.append(self.no_encrypt)
279+
box.append(row)
271280
self.pp1 = Gtk.PasswordEntry(show_peek_icon=True)
272281
self.pp2 = Gtk.PasswordEntry(show_peek_icon=True)
273-
self.encrypt.connect("notify::active", lambda *_: [w.set_sensitive(self.encrypt.get_active()) for w in (self.pp1, self.pp2)])
274-
box.append(self.form([("Encrypt the disk (LUKS2)", self.encrypt), ("Disk passphrase", self.pp1),
275-
("Passphrase again", self.pp2)]))
276-
box.append(label("The passphrase is asked at every boot. If you lose it, the data cannot be recovered.", "muted"))
282+
self.pp_form = self.form([("Disk passphrase", self.pp1), ("Passphrase again", self.pp2)])
283+
self.encrypt.connect("toggled", lambda *_: self.pp_form.set_visible(self.encrypt.get_active()))
284+
box.append(self.pp_form)
277285
self.disk_err = label("", "error")
278286
box.append(self.disk_err)
279287
return "disk", sc
@@ -411,6 +419,7 @@ def fill_review(self):
411419
f"Computer name: {self.hostname.get_text().strip()}",
412420
f"User: {self.username.get_text().strip()} ({self.fullname.get_text().strip()}), administrator via doas",
413421
"W3BS: w3bs CLI and the Agentic Desktop Layer (agent access OFF until you turn it on)",
422+
"Dev tools: curl, wget, mise (bun, pnpm), Node and readm3",
414423
]
415424
while (child := self.review.get_first_child()) is not None:
416425
self.review.remove(child)
@@ -531,7 +540,7 @@ def autowalk(self):
531540
w.set_text(TEST_PW)
532541
if name == "disk":
533542
if os.environ.get("W3BS_GUI_TEST_NOENCRYPT"):
534-
self.encrypt.set_active(False)
543+
self.no_encrypt.set_active(True)
535544
elif TEST_PW:
536545
for w in (self.pp1, self.pp2):
537546
w.set_text(TEST_PW + "-luks")

‎package-manager/crates/w3bs-core/src/repo.rs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,14 @@ pub async fn load(layout: &Layout, alias: &str, base_url: &str, key: &str) -> Re
106106
let dir = layout.trust_dir(key);
107107
let initial = std::fs::read(dir.join("initial-root.json"))
108108
.map_err(|e| Error::preflight("TRUST_STATE", format!("trust root for repository `{alias}` is missing: {e}; run `w3bs repo remove {alias}` and add it again")))?;
109-
// The datastore holds the newest root reached through verified rotation; prefer it.
110-
let anchor = std::fs::read(dir.join("root.json")).unwrap_or_else(|_| initial.clone());
109+
// The datastore holds the newest root reached through verified rotation; prefer it. An empty
110+
// or unparseable one (a write cut short: seen as a 0-byte root.json after a W3BS OS install)
111+
// would fail every load for good, so fall back to the pinned initial root and let TUF walk
112+
// the rotations again.
113+
let anchor = match std::fs::read(dir.join("root.json")) {
114+
Ok(b) if serde_json::from_slice::<serde_json::Value>(&b).is_ok() => b,
115+
_ => initial.clone(),
116+
};
111117
let base = normalize_base(base_url, layout.dev_transport)?;
112118
let repo = RepositoryLoader::new(&anchor, sub(&base, "metadata/"), sub(&base, "targets/"))
113119
.transport(W3bsTransport::new(layout.dev_transport))

0 commit comments

Comments
 (0)