#!/usr/bin/env bash # Arcline OS — live session: start X as an unprivileged user, then launch the # graphical installer as root on that display. # # Modern Xorg (Debian trixie 21.1.x) refuses to run as root — the # --allow-root / -allowRoot option was removed. So X runs as the dedicated # `liveuser` account, root is granted display access, and the installer (which # needs root to run deploy-disk.sh) connects to it. set -euo pipefail export DISPLAY=:0 LXUSER=liveuser VT=1 TTY="/dev/tty$VT" # udev leaves console VTs as 620 root:tty — group tty has write-only, no read, # so Xorg's xf86OpenConsole fails with "Cannot open virtual console (Permission # denied)". This VT is dedicated to the installer (the unit Conflicts with # getty@tty1), so hand it to liveuser outright. chown "$LXUSER" "$TTY" 2>/dev/null || true # clear stale X state from a previous attempt in the same boot rm -f /tmp/.X0-lock /tmp/.X11-unix/X0 2>/dev/null || true # 1. start Xorg as the unprivileged user on vt1 (no -allow-root; it's gone) runuser -u "$LXUSER" -- /usr/bin/Xorg :0 "vt$VT" -nolisten tcp & XPID=$! # 2. wait for the X socket for _ in $(seq 1 60); do [[ -S /tmp/.X11-unix/X0 ]] && break sleep 0.5 done [[ -S /tmp/.X11-unix/X0 ]] || { echo "error: Xorg did not come up on :0" >&2; kill "$XPID" 2>/dev/null || true; exit 1; } # 3. let root open windows on this display runuser -u "$LXUSER" -- xhost +SI:localuser:root >/dev/null 2>&1 || true # 4. run the installer as root (deploy-disk.sh needs root) runuser -u root -- env DISPLAY=:0 /usr/local/bin/arcline-installer rc=$? kill "$XPID" 2>/dev/null || true exit "$rc"