a new box installs in one go: the docker group, python3-dev and ffmpeg

NVIDIA's first-boot setup leaves the account it creates out of the docker group (its oobe-admin,
DGX OS 7.6.0 on an ASUS GX10), and DGX OS 7.6.0 has neither python3-dev nor ffmpeg: the one-liner
stopped at its first check on every new box, and past it the image and video lanes stopped on the
packages. lanes.sh now has docker_grant (install.sh's step 1, after every refusal that comes before
it: the account added with sudo, said first, then the run started again with the group; --no-service
says how instead), docker_session (a terminal older than the group: install.sh, switch-model.sh,
prepare-lane.sh, uninstall.sh and the lanes' installers start again with it), docker_relaunch (sg
docker, then back to the account's own group, with the environment the run started with, no value of
it in a command line, and the signals it ignored) and host_packages (install.sh puts in what the image
and video lanes need while its terminal can give sudo its password, once per run, and the lanes'
installers do the same from a terminal). SECURITY.md and the README say what the installer does on a
new box. tests/test_fresh_machine.py: 56 cases, 55 failing on the code before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Hasan BasbunarandClaude Opus 5.5 committed 2026-10-21 01:15:11 +02:00
1 parent 28adc55919
commit d782f94391
17 files changed
+1053 -7

No files matched your search

+1 -1
View File
@@ -159,7 +159,7 @@ The engine answers `/health` even when it is wedged, so the cockpit runs a real
## Quickstart
Requirements: DGX Spark or other GB10 machine (128 GB unified), stock DGX OS (Docker + NVIDIA container toolkit). The image and video lanes also build one package against Python's headers, which DGX OS leaves out: `sudo apt-get install -y python3-dev` first (each lane asks for it before it downloads anything). Free disk for the whole box: about **852 GB** (GB of 10^9 bytes, rounded up), as the lanes measure on the reference box: the 27B lane 58 GB (22 checkpoint, 2 draft, 34 image), the flash lane 223 (136 checkpoint, 35 image, 52 for the PLE table it rewrites at every boot), the image lane 46 (34 checkpoint, 12 runtime and its build), the video lane 174 (145 checkpoint and its Turbo adapter, 12 runtime and its build, 17 for the runtime's own caches), the Kolibri lane 102 (79 checkpoint, 23 image), the Nemotron lane 51 (26 checkpoint and drafter, 25 image), the Nemotron Super lane 77 (its checkpoint and drafter; it runs the Nemotron lane's image, 102 without it) and the Flash FP4-Local lane 121 (103 checkpoint, 18 image, and 32 more for the copy of its n-gram table when the cache is on another disk than the home directory's, [docs/external-disk.md](docs/external-disk.md)). Each lane checks its own room before it downloads anything (a lane on demand, at its first Load), and a lane installed whole that does not fit is left out and named at the end, with the command that adds it later, while the rest installs. What the text lanes check, in detail: for a 27B target, **49 GB** on the disk of `HF_CACHE` (`~/.cache/huggingface` by default) for the checkpoints and caches, and **52 GB** on the disk of Docker's images (`/var/lib/docker` on a stock box) for its 34 GB image (a pull's peak: Docker's containerd image store keeps the download beside the image); for a flash target, **248 GB** on the disk of `HF_CACHE` (194 for the checkpoint and its caches, 54 for the 52 GB PLE table the lane rewrites at every boot, counted on the disk of `PLE_DIR` instead when that is another one) and **53 GB** there for its 35 GB image. When both are one disk, as on a stock box, the installer asks for the sum there: **101 GB** for a 27B target, **301 GB** for a flash one. What the cache already holds of a checkpoint comes off its share (a checkpoint that is all there needs 11 GB of working room instead), and an image already pulled needs 6 GB instead of its own size. Caching the other 27B targets adds ~22 GB per NVFP4 target and ~31 GB per FP8 one.
Requirements: DGX Spark or other GB10 machine (128 GB unified), stock DGX OS (Docker + NVIDIA container toolkit). What a new box lacks, the installer puts in itself: DGX OS's first-boot setup leaves the account it creates out of the `docker` group, and leaves out Python's headers and ffmpeg, which the image and video lanes build and run with. The installer adds the account to the group, saying so and why before it runs `sudo`, and goes on in the same terminal, with no need to log out. It installs `python3-dev` and `ffmpeg` (and `python3-venv` where it is missing), naming them as it does. Free disk for the whole box: about **852 GB** (GB of 10^9 bytes, rounded up), as the lanes measure on the reference box: the 27B lane 58 GB (22 checkpoint, 2 draft, 34 image), the flash lane 223 (136 checkpoint, 35 image, 52 for the PLE table it rewrites at every boot), the image lane 46 (34 checkpoint, 12 runtime and its build), the video lane 174 (145 checkpoint and its Turbo adapter, 12 runtime and its build, 17 for the runtime's own caches), the Kolibri lane 102 (79 checkpoint, 23 image), the Nemotron lane 51 (26 checkpoint and drafter, 25 image), the Nemotron Super lane 77 (its checkpoint and drafter; it runs the Nemotron lane's image, 102 without it) and the Flash FP4-Local lane 121 (103 checkpoint, 18 image, and 32 more for the copy of its n-gram table when the cache is on another disk than the home directory's, [docs/external-disk.md](docs/external-disk.md)). Each lane checks its own room before it downloads anything (a lane on demand, at its first Load), and a lane installed whole that does not fit is left out and named at the end, with the command that adds it later, while the rest installs. What the text lanes check, in detail: for a 27B target, **49 GB** on the disk of `HF_CACHE` (`~/.cache/huggingface` by default) for the checkpoints and caches, and **52 GB** on the disk of Docker's images (`/var/lib/docker` on a stock box) for its 34 GB image (a pull's peak: Docker's containerd image store keeps the download beside the image); for a flash target, **248 GB** on the disk of `HF_CACHE` (194 for the checkpoint and its caches, 54 for the 52 GB PLE table the lane rewrites at every boot, counted on the disk of `PLE_DIR` instead when that is another one) and **53 GB** there for its 35 GB image. When both are one disk, as on a stock box, the installer asks for the sum there: **101 GB** for a 27B target, **301 GB** for a flash one. What the cache already holds of a checkpoint comes off its share (a checkpoint that is all there needs 11 GB of working room instead), and an image already pulled needs 6 GB instead of its own size. Caching the other 27B targets adds ~22 GB per NVFP4 target and ~31 GB per FP8 one.
One command, first install and updates alike. It clones or updates `~/dgx-spark-qwen38`, then runs the pinned installer, which installs the 27B, which serves, the keepalive proxy with its typed-decision endpoint, the opencode wiring, the cockpit and its Agent view, and every other lane **on demand**: their units now, and each one prepared at its first Load from the cockpit, as you, with no sudo, then its weights (Flash-Next 176B beside the 27B: 223 GB; images 46, video 174, Kolibri 102, Nemotron 51, Nemotron Super 77 beside it, 102 alone, Flash FP4-Local 121). The 27B proves it serves before the run ends; each other lane is built and started by its first Load. A new box downloads about 39 GB for the 27B (about 6 to 7 minutes at 100 MB/s). `--all-weights` installs the whole box now instead, as every run did before: about an hour and a half of work (92 minutes measured at v1.29.0, before the two Nemotron lanes, the weights cached), plus about 685 GB of downloads (about 114 minutes at 100 MB/s). It ends by printing the cockpit URL, and there is nothing left to run by hand.
+9 -2
View File
@@ -107,7 +107,11 @@ since v1.26.1).
**The cockpit (`dashboard/`, :30090)** runs as the user who installed the box,
and that user is already root-equivalent: `install.sh` requires it to be in the
`docker` group, and a member of that group can start a container with the host's
`/` mounted. The NOPASSWD sudoers lines rendered from
`/` mounted. Since v1.37.2 the installer adds it to that group when it is not in it,
which is how DGX OS's first-boot setup leaves the account it creates. It says so,
and why, before it runs sudo: where sudo asks for the password, a person can stop
there (sudo does not ask while an earlier ticket is still valid, nor for an account
that needs no password). With `--no-service`, which uses no sudo, it says how instead. The NOPASSWD sudoers lines rendered from
`dashboard/sudoers-cockpit.template` add no privilege to that, and they are no
boundary either: two of them `install` a file the user writes
(`~/.config/qwen38/*.switch-stage`) into `/etc/systemd/system`, and with
@@ -137,7 +141,10 @@ pinned revision, the opencode release by its sha256. The image and video lanes
commit and checkpoint revision are pinned, but pip resolves the wheel's dependency tree
from PyPI at install time, with no hash checked. The speech lane (`./install-speech.sh`,
opt-in) pins llama.cpp's commit, its models by sha256, and every package of its venv by
exact version, wheels only, also without hashes. The engine enforces its key, read from a file created
exact version, wheels only, also without hashes. The system packages the image and video
lanes need on a new box (`python3-dev`, `ffmpeg`, and `python3-venv` where it is missing), and
the speech lane's build tools when its installer finds one missing, come from the box's own apt
sources, Ubuntu's signed archive, installed by sudo at the versions its package lists name. The engine enforces its key, read from a file created
0600 and handed to it through SGLang's `--config`, so it is in no process's command line and the chat template and launcher are regenerated from the
repo on every install.
+2
View File
@@ -75,6 +75,8 @@ CONFIG_DIR="$HOME/.config/qwen38"
# the text lane the box comes back to, one record shared with switch-model.sh (lanes.sh)
# shellcheck source=lanes.sh
. "$HERE/lanes.sh"
# A terminal opened before the account joined the docker group: the run goes on with it (lanes.sh).
docker_session bash "$HERE/${BASH_SOURCE[0]##*/}" "$@"
# what the vLLM lanes' installers share: the engine's cache and port, the uninstall, the service,
# the preflight and the room, the fetch, the proof
# shellcheck source=vllm-lane.sh
+9
View File
@@ -63,6 +63,8 @@ CONFIG_DIR="$HOME/.config/qwen38"
# the text lane the box comes back to, one record shared with switch-model.sh (lanes.sh)
# shellcheck source=lanes.sh
. "$HERE/lanes.sh"
# A terminal opened before the account joined the docker group: the run goes on with it (lanes.sh).
docker_session bash "$HERE/${BASH_SOURCE[0]##*/}" "$@"
LANE_DIR="${IMAGE_LANE_DIR:-$(installed WorkingDirectory)}"; LANE_DIR="${LANE_DIR:-$HOME/.local/share/qwen38-image}"
VENV="$LANE_DIR/venv"
SRC="$LANE_DIR/sglang"
@@ -239,6 +241,13 @@ step "1/6 Preflight"
case "$(uname -m)" in aarch64|arm64) : ;; *) die "this lane is verified on the DGX Spark's ARM64 GB10 only (this box is $(uname -m))." ;; esac
command -v nvidia-smi >/dev/null || die "nvidia-smi not found: this needs the NVIDIA driver."
command -v git >/dev/null || die "git is required (stock on DGX OS)."
# Run from a terminal, this installs what the lane needs and the box lacks (lanes.sh
# host_packages). The checks below, as before, say what could not be put in: the cockpit's
# runs have no terminal for sudo's password, and install.sh puts these in for them.
HOST_PKGS=()
python3 -c 'import venv, ensurepip' 2>/dev/null || HOST_PKGS+=(python3-venv)
[ -f "$(python3 -c 'import sysconfig; print(sysconfig.get_paths()["include"])' 2>/dev/null)/Python.h" ] || HOST_PKGS+=(python3-dev)
[ "${#HOST_PKGS[@]}" -eq 0 ] || host_packages "the image lane" "${HOST_PKGS[@]}" || true
# ensurepip, not just venv: venv is in python3's standard library either way, and it is
# python3-venv that ships ensurepip, which gives a venv its pip. Checked on venv alone,
# a box without the package made a venv with no pip (found in review, 2026-09-24).
+2
View File
@@ -69,6 +69,8 @@ CONFIG_DIR="$HOME/.config/qwen38"
# the text lane the box comes back to, one record shared with switch-model.sh (lanes.sh)
# shellcheck source=lanes.sh
. "$HERE/lanes.sh"
# A terminal opened before the account joined the docker group: the run goes on with it (lanes.sh).
docker_session bash "$HERE/${BASH_SOURCE[0]##*/}" "$@"
# what the three vLLM lanes' installers share: the engine's cache and port, the uninstall, the
# service, the preflight and the room, the fetch, the proof
# shellcheck source=vllm-lane.sh
+2
View File
@@ -62,6 +62,8 @@ CONFIG_DIR="$HOME/.config/qwen38"
# the text lane the box comes back to, one record shared with switch-model.sh (lanes.sh)
# shellcheck source=lanes.sh
. "$HERE/lanes.sh"
# A terminal opened before the account joined the docker group: the run goes on with it (lanes.sh).
docker_session bash "$HERE/${BASH_SOURCE[0]##*/}" "$@"
# what the three vLLM lanes' installers share: the engine's cache and port, the uninstall, the
# service, the preflight and the room, the fetch, the proof
# shellcheck source=vllm-lane.sh
+2
View File
@@ -61,6 +61,8 @@ CONFIG_DIR="$HOME/.config/qwen38"
# the text lane the box comes back to, one record shared with switch-model.sh (lanes.sh)
# shellcheck source=lanes.sh
. "$HERE/lanes.sh"
# A terminal opened before the account joined the docker group: the run goes on with it (lanes.sh).
docker_session bash "$HERE/${BASH_SOURCE[0]##*/}" "$@"
# what the three vLLM lanes' installers share: the engine's cache and port, the uninstall, the
# service, the preflight and the room, the fetch, the proof
# shellcheck source=vllm-lane.sh
+13
View File
@@ -28,6 +28,9 @@ UNIT=qwen38-speech.service
INSTALLED="/etc/systemd/system/$UNIT"
die(){ printf '\n\033[1;31mERROR:\033[0m %s\n' "$*" >&2; exit 1; }
step(){ printf '\n\033[1;36m── %s\033[0m\n' "$*"; }
# what the lanes' installers share; this one takes host_packages from it
# shellcheck source=lanes.sh
. "$HERE/lanes.sh"
# Under sudo every path below moves to /root. install.sh refuses the same way.
if [ "$(id -u)" = "0" ] && [ "${ALLOW_ROOT:-0}" != "1" ]; then
@@ -144,6 +147,16 @@ fi
step "1/6 Preflight"
case "$(uname -m)" in aarch64|arm64) : ;; *) die "this lane is verified on the DGX Spark's ARM64 GB10 only (this box is $(uname -m))." ;; esac
# Run from a terminal, this installs what the lane needs and the box lacks (lanes.sh
# host_packages), each tool by the package that has it. The checks below, as before, say what
# could not be put in.
HOST_PKGS=()
for t in git:git curl:curl cmake:cmake c++:build-essential sha256sum:coreutils taskset:util-linux; do
command -v "${t%%:*}" >/dev/null || HOST_PKGS+=("${t#*:}")
done
command -v ffmpeg >/dev/null || HOST_PKGS+=(ffmpeg)
python3 -c 'import venv, ensurepip' 2>/dev/null || HOST_PKGS+=(python3-venv)
[ "${#HOST_PKGS[@]}" -eq 0 ] || host_packages "the speech lane" "${HOST_PKGS[@]}" || true
for t in git curl cmake c++ sha256sum taskset; do
command -v "$t" >/dev/null || die "$t is missing. Fix: sudo apt-get install -y git curl cmake build-essential coreutils util-linux"
done
+10
View File
@@ -70,6 +70,8 @@ CONFIG_DIR="$HOME/.config/qwen38"
# the text lane the box comes back to, one record shared with switch-model.sh (lanes.sh)
# shellcheck source=lanes.sh
. "$HERE/lanes.sh"
# A terminal opened before the account joined the docker group: the run goes on with it (lanes.sh).
docker_session bash "$HERE/${BASH_SOURCE[0]##*/}" "$@"
LANE_DIR="${VIDEO_LANE_DIR:-$(installed WorkingDirectory)}"; LANE_DIR="${LANE_DIR:-$HOME/.local/share/qwen38-video}"
VENV="$LANE_DIR/venv"
SRC="$LANE_DIR/sglang"
@@ -236,6 +238,14 @@ step "1/6 Preflight"
case "$(uname -m)" in aarch64|arm64) : ;; *) die "this lane is verified on the DGX Spark's ARM64 GB10 only (this box is $(uname -m))." ;; esac
command -v nvidia-smi >/dev/null || die "nvidia-smi not found: this needs the NVIDIA driver."
command -v git >/dev/null || die "git is required (stock on DGX OS)."
# Run from a terminal, this installs what the lane needs and the box lacks (lanes.sh
# host_packages). The checks below, as before, say what could not be put in: the cockpit's
# runs have no terminal for sudo's password, and install.sh puts these in for them.
HOST_PKGS=()
{ command -v ffmpeg && command -v ffprobe; } >/dev/null 2>&1 || HOST_PKGS+=(ffmpeg)
python3 -c 'import venv, ensurepip' 2>/dev/null || HOST_PKGS+=(python3-venv)
[ -f "$(python3 -c 'import sysconfig; print(sysconfig.get_paths()["include"])' 2>/dev/null)/Python.h" ] || HOST_PKGS+=(python3-dev)
[ "${#HOST_PKGS[@]}" -eq 0 ] || host_packages "the video lane" "${HOST_PKGS[@]}" || true
# The MiniMax-H3 pipeline requires ffmpeg and ffprobe for media processing and
# validated output delivery, and refuses to start without them (its own words in
# minimax_h3_pipeline.py). Installed from the OS package, once, before anything else.
+40 -1
View File
@@ -675,6 +675,17 @@ done
[ "$PLAN_ONLY" -eq 0 ] || [ "$NO_SERVICE" -eq 0 ] \
|| die "--plan lists what a run does to the box's services; --no-service writes none."
case "$RECOMMENDED" in 0|1) ;; *) die "QWEN38_RECOMMENDED takes 0 or 1 (got: $RECOMMENDED)" ;; esac
# A terminal opened before its account joined the docker group has none of the group's rights: the
# run goes on with them from here, where it has printed and exported nothing yet (lanes.sh). An
# account outside the group is added at step 1, after every refusal that comes before it.
docker_session bash "$REPO_DIR/${BASH_SOURCE[0]##*/}" "$@"
# Started again by that step 1 (lanes.sh docker_grant): what this run prints up to it is on the
# screen already, from the run that added the account. The runs this one starts print as usual.
DOCKER_SAID=""
if [ "${QWEN38_DOCKER_RELAUNCHED:-}" = granted ]; then
DOCKER_SAID=1; export QWEN38_DOCKER_RELAUNCHED="shown"
exec 3>&1 1>/dev/null
fi
export QWEN38_RECOMMENDED="$RECOMMENDED" # the side lanes' installers this run calls read it
# ── Converge on the operator's installed choices ──
@@ -1492,10 +1503,16 @@ case "$GPU_NAME" in *GB10*) ;; *) echo "WARNING: expected GB10, found '$GPU_NAME
command -v docker >/dev/null || die "docker not found. Install Docker + NVIDIA Container Toolkit (stock on DGX OS)."
command -v python3 >/dev/null || die "python3 not found on the host (needed for the template patcher; stock on DGX OS)."
command -v ss >/dev/null || die "ss not found (iproute2, stock on DGX OS): the preflight cannot check the ports without it."
docker info >/dev/null 2>&1 || die "Cannot talk to the docker daemon. Fix: sudo usermod -aG docker \$USER && re-login (or run with a user in the docker group)."
# /proc/meminfo, not `free`: free(1) localizes its row labels (issue #3)
TOTAL_GB=$(awk '/^MemTotal/{print int($2/1048576)}' /proc/meminfo)
[ "$TOTAL_GB" -ge 110 ] || die "This config needs a ~121 GB unified-memory machine; found ${TOTAL_GB} GB."
# An account outside the docker group, as a new box's is, joins it here, after every refusal above
# (and --help, --plan or a mistyped flag never get here), and the run starts again with it; a daemon
# down or a refusal elsewhere stops with the way out (lanes.sh docker_grant). --no-service uses no
# sudo: it says how instead.
DOCKER_GRANT=yes; [ "$NO_SERVICE" -eq 0 ] || DOCKER_GRANT=no
docker_grant bash "$REPO_DIR/${BASH_SOURCE[0]##*/}" "$@"
[ -z "$DOCKER_SAID" ] || exec 1>&3 3>&-
# A GPU outside its ATS addressing mode cannot start the flash lane (issue #54), and a flash install
# fetches its image and its checkpoint (223 GB in all). A new flash install stops here, before the
# first byte. A run for a box whose flash lane is installed gives it its units only, which say why at
@@ -1645,6 +1662,24 @@ if [ "$NO_SERVICE" -eq 0 ] && ! sudo -n true 2>/dev/null; then
sudo -v || die "sudo could not be used here: run 'sudo -v' in this terminal, then re-run ./install.sh"
fi
echo "OK (aarch64, ${TOTAL_GB} GB RAM, ${FREE_DISK_GB} GB free)"
# What the image and video lanes build or run with, which DGX OS lacks: Python's headers, which
# their first Load builds xatlas against, and ffmpeg, which the video pipeline refuses to start
# without. Installed now, while this terminal can give sudo its password: the first Load runs from
# the cockpit, which has no terminal, and both lanes' installers stopped on it (an ASUS GX10, DGX
# OS 7.6.0, 2026-10-20). Their own checks, the same, still say what an install here could not put.
HOST_PKGS=()
# --no-start and --no-service return before those lanes, and need neither (nor sudo for them)
if [ "$NO_START" -eq 1 ] || [ "$NO_SERVICE" -eq 1 ]; then
:
elif [ "$WANT_IMAGE" -eq 1 ] || [ "$WANT_VIDEO" -eq 1 ]; then
python3 -c 'import venv, ensurepip' 2>/dev/null || HOST_PKGS+=(python3-venv)
[ -f "$(python3 -c 'import sysconfig; print(sysconfig.get_paths()["include"])' 2>/dev/null)/Python.h" ] || HOST_PKGS+=(python3-dev)
fi
if [ "$NO_START" -eq 0 ] && [ "$NO_SERVICE" -eq 0 ] && [ "$WANT_VIDEO" -eq 1 ] \
&& ! { command -v ffmpeg && command -v ffprobe; } >/dev/null 2>&1; then
HOST_PKGS+=(ffmpeg)
fi
[ "${#HOST_PKGS[@]}" -eq 0 ] || host_packages "the image and video lanes" "${HOST_PKGS[@]}" || true
if [ "$UNITS_ONLY" -eq 1 ]; then
if [ -n "$ATS_CANNOT" ]; then step "2/10 The Flash-Next image: not pulled, as this GPU cannot start the flash lane"
@@ -3380,6 +3415,10 @@ except Exception as e:
echo " Anthropic : http://<host>:$PROXY_PORT/v1/messages (Bearer auth only)"
echo " Engine : $ENGINE_BIND:$PORT, behind the proxy (ENGINE_BIND=0.0.0.0 opens it)"
echo " API key : $CONFIG_DIR/api-key"
# started again with the docker group (lanes.sh): the terminal it came from has not got it
if [ -n "${QWEN38_DOCKER_RELAUNCHED:-}" ]; then
echo " Docker : $(id -un) is in the docker group; a terminal opened before this install gets it at its next login (the cockpit and these scripts need nothing)"
fi
if [ "$OPENCODE" -eq 1 ]; then
OC_NOW="$( { opencode --version 2>/dev/null || true; } | tail -1 | tr -d 'v[:space:]')"
# What starts it from the user's own shell: this script's PATH is not theirs, the
+210
View File
@@ -351,3 +351,213 @@ room_per_disk(){
|| die "need ~${need[$dev]} GB free on the disk of ${at[$dev]} for this first Load (${what[$dev]}); found ${free[$dev]:-unknown} GB. Free some space, then Load the lane again: what came already is kept."
done
}
# ── What a box fresh from its first-boot setup lacks, put right where a script needs it ──────────
# The docker group. NVIDIA's first-boot setup puts the account it creates in adm, sudo, audio, dip,
# plugdev, users and lpadmin, never docker (its oobe-admin, DGX OS 7.6.0 on an ASUS GX10), and the
# daemon's socket is root:docker 0660: the engines, the cockpit and these scripts run their
# containers as that account. The one-liner stopped at its first check on every new box, and its
# fix told a desktop user to log out (found on an ASUS GX10, 2026-10-20). An account added to the
# group has it from its next login on; a terminal opened before, the install's own included, keeps
# the groups of its login, and the scripts run from it come through docker_session.
# A script started again by docker_relaunch ignores again what it ignored before: sg sets SIGHUP,
# SIGINT, SIGQUIT and the terminal-stop signals back to their defaults in the run it starts, and a
# run under nohup lost its SIGHUP there (measured, 2026-10-20).
for _sig in ${QWEN38_SIG_IGNORED:-}; do
case "$_sig" in HUP|INT|QUIT|TSTP|TTIN|TTOU) trap '' "$_sig" ;; esac
done
unset _sig
docker_in_session(){ # this process has the docker group
local line gid
line="$(getent group docker 2>/dev/null)" || return 1
gid="${line#*:*:}"; gid="${gid%%:*}"
case " $(id -G) " in *" $gid "*) return 0 ;; esac
return 1
}
docker_in_group(){ # the account is in the docker group, as its next login will have it
case " $(id -nG "$(id -un)" 2>/dev/null) " in *" docker "*) return 0 ;; esac
return 1
}
# docker_relaunch_ok CMD...: docker_relaunch below can start CMD again here: not done already; sg,
# env and /proc there; the account's own group with a name (sg takes no number); the account named
# in the docker group's own member list (sg reads that list, and an account a directory service puts
# in the group without it is asked a group password there); and no word of CMD, of the paths of sg
# and env, of the account's group, or of a value to hand back past sg, holding a character sg's
# `sh -c` would read as its own.
docker_relaunch_ok(){
local v line own
[ -z "${QWEN38_DOCKER_RELAUNCHED:-}" ] || return 1
command -v sg >/dev/null 2>&1 && command -v env >/dev/null 2>&1 && [ -r "/proc/$$/environ" ] || return 1
own="$(id -gn "$(id -un)" 2>/dev/null)" || return 1
line="$(getent group docker 2>/dev/null)" || return 1
case ",${line##*:}," in *",$(id -un),"*) ;; *) return 1 ;; esac
for v in "$(command -v sg)" "$(command -v env)" "$own" "$@"; do
case "$v" in ''|*[!A-Za-z0-9._/:=@+,-]*) return 1 ;; esac
done
while IFS= read -r -d '' v; do
case "${v%%=*}" in
GCONV_PATH|GETCONF_DIR|GLIBC_TUNABLES|HOSTALIASES|LD_*|LOCALDOMAIN|LOCPATH|MALLOC_*|NIS_PATH|NLSPATH|RESOLV_HOST_CONF|RES_OPTIONS|TMPDIR|TZDIR)
case "$v" in *[!A-Za-z0-9._/:=@+,-]*) return 1 ;; esac ;;
esac
done < "/proc/$$/environ"
return 0
}
# docker_relaunch WHY CMD...: CMD again, with the groups a new login has, for the rest of this run:
# sg to docker, then to the account's own group, which a lone `sg docker` leaves in docker's place (the
# units take it for their Group=; measured on the reference box, 2026-10-20). sg runs CMD as a child
# it waits for and passes its exit status back (measured): the run is then the child of the second sg
# and the grandchild of the first, both waiting with SIGINT and SIGHUP ignored, so it stops by its
# process group (Ctrl+C, systemd, the cockpit), and a kill of the first PID stops only that sg. CMD
# gets the environment this process started with: what it exported since is taken out, what it
# changed is set back. The start's values it left as they were pass in the environment, never in a
# command line; those it changed are set back as env's arguments, and the variables the C library
# takes from a setuid program's environment (TMPDIR and the like), handed back after sg, go into its
# `sh -c` line: neither is a key the scripts read. The signals this process ignores
# are ignored again (lanes.sh, above), and WHY is said to the run it starts (QWEN38_DOCKER_RELAUNCHED).
# Returns 1, having run nothing, where docker_relaunch_ok says no or a step here fails: the callers
# then say the way out.
docker_relaunch(){
local why="$1" sg envp own n v back="" ign="" mask sig
local -a start=() fix=()
local -A at_start=()
shift
docker_relaunch_ok "$@" || return 1
sg="$(command -v sg)" && envp="$(command -v env)" && own="$(id -gn "$(id -un)")" || return 1
mapfile -d '' -t start < "/proc/$$/environ" 2>/dev/null || return 1
for v in "${start[@]}"; do
n="${v%%=*}"
case "$n" in ''|[0-9]*|*[!A-Za-z0-9_]*) continue ;; esac
at_start[$n]="${v#*=}"
case "$n" in
GCONV_PATH|GETCONF_DIR|GLIBC_TUNABLES|HOSTALIASES|LD_*|LOCALDOMAIN|LOCPATH|MALLOC_*|NIS_PATH|NLSPATH|RESOLV_HOST_CONF|RES_OPTIONS|TMPDIR|TZDIR)
back="$back $v" ;;
esac
done
while IFS= read -r n; do
[ -n "${at_start[$n]+x}" ] || fix+=(-u "$n")
done < <(compgen -e)
for n in "${!at_start[@]}"; do
case "$n" in _|SHLVL|PWD|OLDPWD) continue ;; esac
if [ "${!n-}" != "${at_start[$n]}" ] || ! printenv "$n" >/dev/null; then
fix+=("$n=${at_start[$n]}")
fi
done
mask="$(awk '/^SigIgn:/ {print $2}' "/proc/$$/status" 2>/dev/null)" || mask=0
for sig in 1:HUP 2:INT 3:QUIT 20:TSTP 21:TTIN 22:TTOU; do
[ $(( 0x${mask:-0} >> (${sig%%:*} - 1) & 1 )) -eq 0 ] || ign="$ign ${sig#*:}"
done
exec "$envp" "${fix[@]}" QWEN38_DOCKER_RELAUNCHED="$why" QWEN38_SIG_IGNORED="${ign# }" \
"$sg" docker -c "exec $sg $own -c 'exec $envp$back $*'"
}
# docker_session CMD...: the account is in the docker group and this process is not (its terminal
# was opened before the account joined): CMD again with the group, as from a new login. Otherwise
# nothing: a docker that refuses for another reason says so where it is reached.
docker_session(){
docker_in_session && return 0
docker_in_group || return 0
if docker_relaunch_ok "$@"; then
echo "Docker: $(id -un) is in the docker group, and this terminal was opened before it joined; going on with the group (no need to log out)."
docker_relaunch session "$@" || true
fi
die "Docker: this terminal was opened before $(id -un) joined the docker group, and this run cannot start again with it here. Log out and back in (or open a new SSH session), then the same command again."
}
# docker_grant CMD...: docker answers, or this run makes it answer and runs CMD again. A refusal on
# the system's socket (root:docker) of an account outside the group is put right with sudo, said
# before sudo runs: where it asks for the password, a person can stop there. A run that cannot start
# again here (docker_relaunch_ok) still gets the account added, and says to log in again instead of
# going on. DOCKER_GRANT=no (a run that uses no sudo) says how instead. A daemon that is not running,
# a refusal anywhere else (DOCKER_HOST, a context, a rootless Docker), an account sudo refuses or that
# a directory service keeps: each stops with its own way out. No docker command at all is left to the
# caller's own check.
docker_grant(){
local err who
command -v docker >/dev/null 2>&1 || return 0
err="$(docker info 2>&1 >/dev/null)" && return 0
who="$(id -un)"
case "$err" in
*/run/docker.sock*) ;;
*) die "docker does not answer: $(printf '%s' "$err" | tr '\n' ' ' | cut -c1-300)" ;;
esac
case "$err" in
*[Pp]"ermission denied"*) ;;
*"daemon is running"*|*"docker daemon running"*|*"Cannot connect to the Docker daemon"*)
die "Docker is installed, but its service is not running. Run sudo systemctl enable --now docker, then the same command again." ;;
*) die "docker does not answer: $(printf '%s' "$err" | tr '\n' ' ' | cut -c1-300)" ;;
esac
[ "$(stat -L -c %G /run/docker.sock 2>/dev/null)" = docker ] \
|| die "docker refuses $who on /run/docker.sock, which is not the docker group's ($(stat -L -c '%U:%G %a' /run/docker.sock 2>/dev/null)): $(printf '%s' "$err" | head -1 | cut -c1-200)"
docker_in_session \
&& die "docker refuses $who on /run/docker.sock, although this process has the docker group: $(printf '%s' "$err" | head -1 | cut -c1-200)"
docker_session "$@"
if [ "${DOCKER_GRANT:-yes}" = no ]; then
die "Docker: $who is not in the docker group, which the engines run their containers through (the box's first-boot setup leaves it out), and this run uses no sudo. Run sudo usermod -aG docker $who, log out and back in, then the same command again."
fi
echo "Docker: $who is not in the docker group, which the engines and the cockpit run their containers through (the box's first-boot setup leaves it out)."
echo "Docker: adding it now, with sudo. A member of that group can run any container, which makes it root on this machine (SECURITY.md)."
sudo usermod -aG docker "$who" \
|| die "Docker: $who could not be added to the docker group. Run sudo usermod -aG docker $who, log out and back in, then the same command again."
docker_in_group \
|| die "Docker: usermod said yes, and $who is still not in the docker group (an account of a directory service?). Have it added there, log in again, then the same command again."
if docker_relaunch_ok "$@"; then
echo "Docker: $who is in the docker group now; this run goes on with it (no need to log out)."
docker_relaunch granted "$@" || true
fi
die "Docker: $who is in the docker group now, and this run cannot start again with it here. Log out and back in (or open a new SSH session), then the same command again."
}
# host_packages WHY PKG...: Ubuntu packages a lane builds or runs with, which the caller found
# missing, installed with sudo, named first. Only where sudo can ask (a terminal) or need not (a
# ticket): the cockpit's Loads have neither, so install.sh puts these in while its terminal is there
# (DGX OS 7.6.0 has neither python3-dev nor ffmpeg; found on an ASUS GX10, 2026-10-20). Once per run:
# the lanes' installers that install.sh calls do not try again. apt is told it has no one to ask
# (needrestart asked in the terminal), or, where sudo says it may not set those variables (a rule for
# apt-get alone), run without them. A sudo that refuses the account or its password is not asked
# again. apt waits up to five minutes for another package manager, and a lock still held then is said
# rather than waited for again. Lists too old for the archive are refreshed once. sudo and apt speak
# English here (LC_ALL=C), whatever the account's language, so that their words can be read. Returns
# 1 when they could not be installed, saying the command: the caller's own check then says what is
# missing.
host_packages(){
local why="$1" rc out
shift
[ "$#" -gt 0 ] || return 0
[ -z "${QWEN38_HOST_PACKAGES_TRIED:-}" ] || return 1
export QWEN38_HOST_PACKAGES_TRIED=1
if ! sudo -n true 2>/dev/null && ! { : < /dev/tty; } 2>/dev/null; then
echo "NOTE: missing on this box, for $why: $*. No terminal is here for sudo to ask its password: run sudo apt-get install -y $* yourself." >&2
return 1
fi
echo "Installing $* for $why, missing on this box (sudo apt-get install -y $*)."
out="$(mktemp)"
local -a apt=(sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=l apt-get -o DPkg::Lock::Timeout=300 -q -y)
if LC_ALL=C "${apt[@]}" install "$@" 2> "$out"; then rm -f "$out"; return 0; else rc=$?; fi
cat "$out" >&2
# sudo itself said no (a wrong password three times, an account outside sudoers): never asked again
if [ "$rc" -eq 1 ] && grep -q -E "incorrect password|password is required|not in the sudoers|not allowed to (run|execute)" "$out"; then
rm -f "$out"
echo "NOTE: sudo refused; run sudo apt-get install -y $* yourself." >&2
return 1
fi
if [ "$rc" -eq 1 ] && grep -q "not allowed to set" "$out"; then
apt=(sudo apt-get -o DPkg::Lock::Timeout=300 -q -y)
if LC_ALL=C "${apt[@]}" install "$@" 2> "$out"; then rm -f "$out"; return 0; fi
cat "$out" >&2
fi
if grep -q -E "Could not get lock|Unable to acquire the dpkg frontend lock" "$out"; then
rm -f "$out"
echo "NOTE: another package manager held apt's lock; run sudo apt-get install -y $* once it is done." >&2
return 1
fi
rm -f "$out"
"${apt[@]}" update || true
if "${apt[@]}" install "$@"; then return 0; fi
echo "NOTE: apt-get could not install $*; run sudo apt-get install -y $* yourself." >&2
return 1
}
+2
View File
@@ -179,6 +179,8 @@ case "$1" in
CONFIG_DIR="$HOME/.config/qwen38"; REPO_DIR="$HERE"
# shellcheck source=lanes.sh
. "$HERE/lanes.sh"
# a terminal opened before the account joined the docker group: on with the group (lanes.sh)
docker_session bash "$HERE/${BASH_SOURCE[0]##*/}" "$@"
pins_or_die
if [ "$1" = flash ]; then prepare_flash; else prepare_27b; fi ;;
*) usage ;;
+2
View File
@@ -103,6 +103,8 @@ dl_free_gb(){ { df -BG --output=avail "$(existing "${1:-$HF_CACHE}")" 2>/dev/nul
# notes the SGLang text unit it takes the boot from, a switch to a text target notes its own.
# shellcheck source=lanes.sh
. "$REPO_DIR/lanes.sh"
# A terminal opened before the account joined the docker group: the run goes on with it (lanes.sh).
docker_session bash "$REPO_DIR/${BASH_SOURCE[0]##*/}" "$@"
[ "$FETCH_ONLY" -eq 1 ] || text_lane_migrate
# ── The Kolibri lane: a text lane on vLLM, switched to the way the image lane is ────
+725
View File
@@ -0,0 +1,725 @@
#!/usr/bin/env python3
"""A box fresh from its first-boot setup installs in one run: the docker group and the packages.
NVIDIA's first-boot setup puts the account it creates in adm, sudo, audio, dip, plugdev, users and
lpadmin, never docker (its oobe-admin, DGX OS 7.6.0 on an ASUS GX10), and the socket is root:docker
0660. The one-liner stopped at its first check on every new box, its fix telling a desktop user to
log out; past it, the image and video lanes stopped on python3-dev and ffmpeg, which DGX OS 7.6.0
has neither of (found on an ASUS GX10, 2026-10-20). lanes.sh puts both right where a script needs
them: docker_grant adds the account (said before sudo runs) at install.sh's step 1, after every
refusal that comes before it; docker_session runs a script again with the group when its terminal
predates it; docker_relaunch does that with the groups a new login has, the environment the
process started with (its unchanged values in the environment, never in a command line) and the
signals it ignored; host_packages
installs what a lane lacks while a terminal can give sudo its password, once per run.
Each case runs the real functions under bash with stand-ins for docker, id, getent, stat, sudo, sg
and env (which record what they were asked, sg the environment it got), and install.sh, get.sh and
uninstall.sh run whole up to a wall, so a relaunch that does not happen shows as the wall.
"""
import os
import pathlib
import shutil
import subprocess
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import installer_wall as wall # noqa: E402
REPO = pathlib.Path(__file__).resolve().parents[1]
LANES = REPO / "lanes.sh"
DENIED = ("permission denied while trying to connect to the docker API at "
"unix:///var/run/docker.sock") # Docker 29.6.2, the GX10, 2026-10-20
DENIED_OLD = ("permission denied while trying to connect to the Docker daemon socket at "
"unix:///var/run/docker.sock: Get \"http://%2Fvar%2Frun%2Fdocker.sock/v1.47/info\": "
"dial unix /var/run/docker.sock: connect: permission denied")
DOWN = ("failed to connect to the docker API at unix:///var/run/docker.sock; check if the path is "
"correct and if the daemon is running: dial unix /var/run/docker.sock: connect: no such "
"file or directory") # Docker 29.6.2, measured 2026-10-20
DOWN_OLD = ("Cannot connect to the Docker daemon at unix:///var/run/docker.sock. "
"Is the docker daemon running?")
MEMINFO = "MemTotal: 127541200 kB\nMemAvailable: 121000000 kB\n"
class Box:
"""Stand-ins for what the functions ask the machine, in a directory first on PATH.
The account is alice (her group alice, gid 1000; docker's gid is 988). `in_session` puts 988 in
this process's groups, `member` puts docker in the account's groups as a new login reads them,
and a granted usermod adds it there. `id -gn` alone answers docker, as in a shell after
`newgrp docker`; asked about alice, it answers her own group. sudo and sg print a marker on
stdout when they run, so that the order of what was said around them can be read. sg records its
argv and the environment it got, then exits 0: a relaunch ends the run there."""
def __init__(self, docker_err=DENIED, docker_rc=1, member=False, in_session=False,
sock_group="docker", sudo_n=1, usermod_rc=0, usermod_adds=True,
apt_rcs=(0,), docker_group=True, with_sg=True, sudo_refuses_env=False,
listed=True, apt_err="", apt_err_fr="", group_nameless=False):
self.d = wall._tmp("fresh-")
self.bin = self.d / "bin"
self.bin.mkdir()
# the real tools the functions and the stand-ins use, and nothing else: no sg, sudo,
# docker or apt-get of the machine can be reached from a case
self.tools = self.d / "tools"
self.tools.mkdir()
for t in ("cat", "head", "sed", "basename", "dirname", "tr", "cut", "awk", "printenv", "grep", "xargs",
"mktemp", "rm"):
(self.tools / t).symlink_to(shutil.which(t))
self.calls = self.d / "calls"
self.calls.touch()
(self.d / "docker.err").write_text(docker_err)
(self.d / "nG").write_text("alice sudo docker" if member else "alice sudo")
(self.d / "apt.rcs").write_text("\n".join(str(r) for r in apt_rcs) + "\n")
groups = "1000 27 988" if in_session else "1000 27"
rec = f'echo "$(basename "$0") $*" >> "{self.calls}"\n'
stubs = {
"docker": rec + f'[ "$1" = info ] || exit 0\ncat "{self.d}/docker.err" >&2\nexit {docker_rc}\n',
"id": ('case "$1 ${2-}" in\n "-u ") echo 1000 ;;\n "-un ") echo alice ;;\n'
' "-gn ") echo docker ;;\n'
+ (' "-gn alice") echo 1000; exit 1 ;;\n' if group_nameless else ' "-gn alice") echo alice ;;\n')
+ f' "-G ") echo "{groups}" ;;\n "-nG alice") cat "{self.d}/nG" ;;\n'
' *) exec /usr/bin/id "$@" ;;\nesac\n'),
# the group's own member list, which sg reads: alice there once she is a member,
# unless a directory service puts her in the group without it (listed=False)
"getent": (('[ "$*" = "group docker" ] || exec /usr/bin/getent "$@"\n'
+ (f'grep -qw docker "{self.d}/nG" && [ {int(listed)} -eq 1 ] && '
'echo docker:x:988:alice && exit 0\necho docker:x:988:\nexit 0\n'
if docker_group else 'exit 2\n'))),
"stat": ('case "$*" in\n'
f' "-L -c %G /run/docker.sock") echo {sock_group} ;;\n'
f' "-L -c %U:%G %a /run/docker.sock") echo "root:{sock_group} 660" ;;\n'
' *) exec /usr/bin/stat "$@" ;;\nesac\n'),
"sudo": (rec + 'case "$*" in\n'
f' "-n true") exit {sudo_n} ;;\n'
' "usermod -aG docker alice")\n echo "[sudo usermod]"\n'
+ (f' [ {usermod_rc} -eq 0 ] && echo "alice sudo docker" > "{self.d}/nG"\n'
if usermod_adds else "")
+ f' exit {usermod_rc} ;;\n'
+ (' DEBIAN_FRONTEND=*)\n if [ "${LC_ALL:-}" = C ]; then echo "sudo: sorry, you are not allowed '
'to set the following environment variables: DEBIAN_FRONTEND" >&2\n'
' else echo "sudo: désolé, vous n\'êtes pas autorisé à définir les variables '
'd\'environnement suivantes : DEBIAN_FRONTEND" >&2; fi\n exit 1 ;;\n' if sudo_refuses_env else "")
+ ' *apt-get*)\n echo "[sudo apt-get]"\n'
f' r=$(head -1 "{self.d}/apt.rcs"); sed -i 1d "{self.d}/apt.rcs"\n'
+ (f' if [ "${{r:-0}}" -ne 0 ]; then if [ "${{LC_ALL:-}}" = C ] || [ -z "{apt_err_fr}" ]; '
f'then echo "{apt_err}" >&2; else echo "{apt_err_fr}" >&2; fi; fi\n' if apt_err else '')
+ ' exit "${r:-0}" ;;\n'
'esac\nexit 0\n'),
# what runs `env` asks it, recorded, then the real one
"env": f'echo "env $*" >> "{self.calls}"\nexec {shutil.which("env")} "$@"\n',
}
if with_sg:
stubs["sg"] = (f'{{ printf "sg"; printf " [%s]" "$@"; echo; }} >> "{self.calls}"\n'
f'echo "[sg]"\n{shutil.which("env")} > "{self.d}/sg.env"\nexit 0\n')
for name, body in stubs.items():
f = self.bin / name
f.write_text("#!/bin/bash\n" + body)
f.chmod(0o755)
def env(self, **extra):
e = {"PATH": f"{self.bin}:{self.tools}", "HOME": str(self.d), "FOO": "a b c",
"SECRET_TOKEN": "s3cr3t-value"}
e.update(extra)
return e
def bash(self, body, **extra):
"""body after lanes.sh, under the installers' own set -euo pipefail and die."""
script = ("set -euo pipefail\n"
"die(){ printf 'ERROR: %s\\n' \"$*\" >&2; exit 1; }\n"
f". '{LANES}'\n" + body)
# a session of its own: no terminal to give sudo a password, wherever the suite runs
r = subprocess.run(["/bin/bash", "-c", script], capture_output=True, text=True, timeout=60,
env=self.env(**extra), stdin=subprocess.DEVNULL, cwd=str(self.d),
start_new_session=True)
return r.returncode, r.stdout, r.stderr
def called(self):
return self.calls.read_text().splitlines()
def sg_calls(self):
return [c for c in self.called() if c.startswith("sg ")]
def env_calls(self):
return [c for c in self.called() if c.startswith("env ")]
def sudo_calls(self):
return [c for c in self.called() if c.startswith("sudo ")]
def sg_env(self):
p = self.d / "sg.env"
return dict(ln.split("=", 1) for ln in p.read_text().splitlines() if "=" in ln) if p.exists() else {}
GRANT = ('export LEAK=late; FOO=changed\n'
'docker_grant bash /opt/q/install.sh --no-video\necho CONTINUED\n')
SESSION = 'docker_session bash /opt/q/switch-model.sh flash\necho CONTINUED\n'
class TheDockerGroup(unittest.TestCase):
def test_docker_that_answers_changes_nothing(self):
box = Box(docker_err="", docker_rc=0)
rc, out, err = box.bash(GRANT)
self.assertEqual(rc, 0, err)
self.assertIn("CONTINUED", out)
self.assertEqual(box.called(), ["docker info"])
def test_an_account_outside_the_group_is_added_then_the_command_runs_again(self):
box = Box()
rc, out, err = box.bash(GRANT, TMPDIR="/var/tmp/alice")
self.assertEqual(rc, 0, err)
self.assertNotIn("CONTINUED", out, "the run went on without the group")
self.assertIn("sudo usermod -aG docker alice", box.sudo_calls())
# said, with why, before sudo runs: on the one stream, the lines come before its marker
self.assertLess(out.index("is not in the docker group"), out.index("[sudo usermod]"))
self.assertLess(out.index("which makes it root on this machine"), out.index("[sudo usermod]"))
self.assertLess(out.index("[sudo usermod]"), out.index("is in the docker group now"))
self.assertLess(out.index("is in the docker group now"), out.index("[sg]"))
# sg to docker, then to the account's own group (alice, not the docker this shell has),
# with the command, and TMPDIR handed back past the setuid sg (glibc drops it there)
sg, = box.sg_calls()
self.assertTrue(sg.startswith("sg [docker] [-c] [exec "), sg)
self.assertRegex(sg, r"/sg alice -c 'exec \S+/env TMPDIR=/var/tmp/alice bash /opt/q/install\.sh --no-video'\]$")
env = box.sg_env()
self.assertEqual(env.get("FOO"), "a b c", "a value changed after the start was not set back")
self.assertNotIn("LEAK", env, "a variable exported after the start reached the relaunch")
self.assertEqual(env.get("SECRET_TOKEN"), "s3cr3t-value")
self.assertEqual(env.get("QWEN38_DOCKER_RELAUNCHED"), "granted")
def test_the_starts_values_pass_in_the_environment_not_in_a_command_line(self):
# a value the run did not change is never an argument; one it changed is set back as one
box = Box()
rc, out, err = box.bash(GRANT)
self.assertEqual(rc, 0, err)
argv = " ".join(box.env_calls() + box.sg_calls())
self.assertNotIn("s3cr3t-value", argv, "a value of the environment showed in a command line")
self.assertIn("-u LEAK", argv)
self.assertIn("FOO=a b c", argv, "the value the script changed is the one set back")
def test_the_older_dockers_wording_is_read_the_same(self):
box = Box(docker_err=DENIED_OLD)
rc, out, err = box.bash(GRANT)
self.assertEqual(rc, 0, err)
self.assertIn("sudo usermod -aG docker alice", box.sudo_calls())
self.assertEqual(len(box.sg_calls()), 1)
def test_a_member_whose_terminal_predates_the_group_is_not_added_again(self):
box = Box(member=True)
rc, out, err = box.bash(GRANT)
self.assertEqual(rc, 0, err)
self.assertEqual(box.sudo_calls(), [])
self.assertIn("this terminal was opened before it joined", out)
self.assertEqual(len(box.sg_calls()), 1)
self.assertEqual(box.sg_env().get("QWEN38_DOCKER_RELAUNCHED"), "session")
def test_a_daemon_that_is_not_running_is_said_and_nothing_is_changed(self):
for text in (DOWN, DOWN_OLD):
with self.subTest(text[:40]):
box = Box(docker_err=text)
rc, out, err = box.bash(GRANT)
self.assertEqual(rc, 1)
self.assertIn("its service is not running", err)
self.assertIn("sudo systemctl enable --now docker", err)
self.assertEqual(box.sudo_calls(), [])
self.assertFalse(box.sg_calls())
def test_a_daemon_out_of_reach_elsewhere_is_not_called_the_systems(self):
# DOCKER_HOST at a socket of the account's own: the system's service is not the way out
box = Box(docker_err="failed to connect to the docker API at unix:///run/user/1000/docker.sock; "
"check if the path is correct and if the daemon is running: dial unix: no such file")
rc, out, err = box.bash(GRANT)
self.assertEqual(rc, 1)
self.assertIn("docker does not answer", err)
self.assertNotIn("systemctl", err)
def test_a_refusal_elsewhere_than_the_systems_socket_touches_no_group(self):
box = Box(docker_err="permission denied while trying to connect to the docker API at "
"unix:///run/user/1000/docker.sock")
rc, out, err = box.bash(GRANT)
self.assertEqual(rc, 1)
self.assertIn("docker does not answer", err)
self.assertEqual(box.sudo_calls(), [])
def test_a_socket_that_is_not_the_docker_groups_touches_no_group(self):
box = Box(sock_group="root")
rc, out, err = box.bash(GRANT)
self.assertEqual(rc, 1)
self.assertIn("which is not the docker group's", err)
self.assertEqual(box.sudo_calls(), [])
def test_a_refusal_with_the_group_in_hand_is_said_as_it_is(self):
box = Box(member=True, in_session=True)
rc, out, err = box.bash(GRANT)
self.assertEqual(rc, 1)
self.assertIn("although this process has the docker group", err)
self.assertFalse(box.sg_calls())
def test_a_run_that_uses_no_sudo_says_how_instead(self):
box = Box()
rc, out, err = box.bash("DOCKER_GRANT=no\n" + GRANT)
self.assertEqual(rc, 1)
self.assertIn("this run uses no sudo", err)
self.assertIn("Run sudo usermod -aG docker alice, log out and back in", err)
self.assertEqual(box.sudo_calls(), [])
def test_sudo_refused_says_the_way_out_and_never_newgrp(self):
box = Box(usermod_rc=1)
rc, out, err = box.bash(GRANT)
self.assertEqual(rc, 1)
self.assertIn("Run sudo usermod -aG docker alice, log out and back in", err)
self.assertNotIn("newgrp", out + err, "newgrp makes docker the shell's own group, and the units' Group=")
self.assertFalse(box.sg_calls())
def test_an_account_usermod_cannot_change_is_said(self):
# an account of a directory service: usermod succeeds on nothing local
box = Box(usermod_adds=False)
rc, out, err = box.bash(GRANT)
self.assertEqual(rc, 1)
self.assertIn("still not in the docker group", err)
self.assertFalse(box.sg_calls())
def test_no_second_relaunch(self):
# started again once already and still refused: the way out, not a loop
box = Box(member=True)
rc, out, err = box.bash(GRANT, QWEN38_DOCKER_RELAUNCHED="granted")
self.assertEqual(rc, 1)
self.assertIn("Log out and back in", err)
self.assertFalse(box.sg_calls())
def test_a_word_sg_would_read_as_its_own_is_never_passed(self):
box = Box()
rc, out, err = box.bash("docker_grant bash /opt/q/install.sh 'a b;touch x'\n")
self.assertEqual(rc, 1)
self.assertIn("this run cannot start again with it here. Log out and back in", err)
# the account is added (its next login needs it), and the run does not say it goes on
self.assertIn("sudo usermod -aG docker alice", box.sudo_calls())
self.assertNotIn("this run goes on with it", out)
self.assertFalse(box.sg_calls())
def test_an_account_whose_own_group_has_no_name_is_told_the_way_out(self):
# id answers a number and fails: sg takes no number, and the run may not end without a word
box = Box(group_nameless=True)
rc, out, err = box.bash(GRANT)
self.assertEqual(rc, 1)
self.assertIn("this run cannot start again with it here. Log out and back in", err)
self.assertNotIn("this run goes on with it", out)
self.assertFalse(box.sg_calls())
def test_an_account_only_a_directory_service_puts_in_the_group_is_not_started_again(self):
# in the group by id, not in the member list sg reads: sg would ask a group password
box = Box(member=True, listed=False)
rc, out, err = box.bash(GRANT)
self.assertEqual(rc, 1)
self.assertIn("Log out and back in", err)
self.assertNotIn("going on with the group", out)
self.assertFalse(box.sg_calls())
def test_a_value_handed_back_that_sg_would_read_stops_rather_than_drops(self):
box = Box(member=True)
rc, out, err = box.bash(GRANT, TMPDIR="/tmp/a b")
self.assertEqual(rc, 1)
self.assertIn("Log out and back in", err)
self.assertFalse(box.sg_calls())
def test_without_sg_the_way_out_is_said(self):
box = Box(member=True, with_sg=False)
rc, out, err = box.bash(GRANT)
self.assertEqual(rc, 1)
self.assertIn("Log out and back in", err)
def test_no_docker_command_is_left_to_the_callers_own_check(self):
box = Box()
(box.bin / "docker").unlink()
rc, out, err = box.bash(GRANT)
self.assertEqual(rc, 0, err)
self.assertIn("CONTINUED", out)
class TheSignalsARunIgnored(unittest.TestCase):
def test_a_run_under_nohup_is_relaunched_with_its_sighup_ignored(self):
box = Box()
rc, out, err = box.bash("trap '' HUP\n" + GRANT)
self.assertEqual(rc, 0, err)
self.assertIn("HUP", box.sg_env().get("QWEN38_SIG_IGNORED", "").split())
def test_the_relaunch_says_exactly_what_the_run_ignored(self):
# whatever the suite's own process ignores (nohup, a background job): read from /proc
# here, it is what the relaunch must say, no more and no less
box = Box()
probe = ("m=$(awk '/^SigIgn:/ {print $2}' /proc/$$/status); w=''\n"
"for s in 1:HUP 2:INT 3:QUIT 20:TSTP 21:TTIN 22:TTOU; do\n"
" [ $(( 0x$m >> (${s%%:*} - 1) & 1 )) -eq 0 ] || w=\"$w ${s#*:}\"\ndone\n"
"echo \"IGNORED=[${w# }]\"\n")
rc, out, err = box.bash(probe + GRANT)
self.assertEqual(rc, 0, err)
said = out.split("IGNORED=[", 1)[1].split("]", 1)[0]
self.assertEqual(box.sg_env().get("QWEN38_SIG_IGNORED"), said)
def test_lanes_sh_ignores_them_again_in_the_run_it_starts(self):
box = Box()
rc, out, err = box.bash("awk '/^SigIgn:/ {print $2}' /proc/$$/status\n", QWEN38_SIG_IGNORED="HUP QUIT")
self.assertEqual(rc, 0, err)
mask = int(out.split()[-1], 16)
self.assertTrue(mask & 1 and mask & 4, f"SIGHUP and SIGQUIT not ignored: {out}")
base = box.bash("awk '/^SigIgn:/ {print $2}' /proc/$$/status\n")[1].split()[-1]
rc, out, err = box.bash("awk '/^SigIgn:/ {print $2}' /proc/$$/status\n", QWEN38_SIG_IGNORED="KILL TERM")
self.assertEqual(out.split()[-1], base, "a name outside the six was acted on")
class ATerminalOlderThanTheGroup(unittest.TestCase):
def test_in_session_nothing_happens(self):
box = Box(member=True, in_session=True)
rc, out, err = box.bash(SESSION)
self.assertEqual(rc, 0, err)
self.assertIn("CONTINUED", out)
self.assertEqual(box.called(), [])
def test_outside_the_group_nothing_happens_here(self):
box = Box(member=False)
rc, out, err = box.bash(SESSION)
self.assertEqual(rc, 0, err)
self.assertIn("CONTINUED", out)
self.assertEqual(box.called(), [])
def test_a_member_outside_its_session_goes_on_with_the_group(self):
box = Box(member=True)
rc, out, err = box.bash(SESSION)
self.assertEqual(rc, 0, err)
self.assertNotIn("CONTINUED", out)
sg, = box.sg_calls()
self.assertRegex(sg, r"/sg alice -c 'exec \S+/env bash /opt/q/switch-model\.sh flash'\]$")
self.assertFalse(box.sudo_calls() + [c for c in box.called() if c.startswith("docker")],
"the session's relaunch needs neither sudo nor docker")
def test_no_docker_group_on_the_box_is_nothing_to_do_here(self):
# a box whose Docker came without its group: no account is in it, nothing to relaunch
box = Box(docker_group=False, member=False)
rc, out, err = box.bash(SESSION)
self.assertEqual(rc, 0, err)
self.assertIn("CONTINUED", out)
class HostPackages(unittest.TestCase):
def test_without_a_terminal_or_a_ticket_it_says_the_command(self):
box = Box(sudo_n=1)
rc, out, err = box.bash('host_packages "the video lane" ffmpeg python3-dev || echo REFUSED\n')
self.assertEqual(rc, 0, err)
self.assertIn("REFUSED", out)
self.assertIn("run sudo apt-get install -y ffmpeg python3-dev yourself", err)
self.assertNotIn("Installing", out, "a run that cannot install said it was installing")
self.assertFalse([c for c in box.called() if "apt-get" in c])
def test_with_a_ticket_it_installs_them_said_first(self):
box = Box(sudo_n=0, apt_rcs=(0,))
rc, out, err = box.bash('host_packages "the video lane" ffmpeg python3-dev && echo DONE\n')
self.assertEqual(rc, 0, err)
self.assertIn("DONE", out)
self.assertLess(out.index("Installing ffmpeg python3-dev for the video lane, missing on this box"),
out.index("[sudo apt-get]"))
apt = [c for c in box.called() if "apt-get" in c]
self.assertEqual(apt, ["sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=l apt-get "
"-o DPkg::Lock::Timeout=300 -q -y install ffmpeg python3-dev"])
def test_a_sudo_rule_for_apt_get_alone_gets_it_without_the_variables(self):
box = Box(sudo_n=0, sudo_refuses_env=True, apt_rcs=(0,))
rc, out, err = box.bash('host_packages "the image lane" python3-dev && echo DONE\n')
self.assertEqual(rc, 0, err)
self.assertIn("DONE", out)
self.assertEqual([c for c in box.called() if "apt-get" in c][-1],
"sudo apt-get -o DPkg::Lock::Timeout=300 -q -y install python3-dev")
def test_lists_too_old_are_refreshed_once(self):
box = Box(sudo_n=0, apt_rcs=(100, 0, 0))
rc, out, err = box.bash('host_packages "the image lane" python3-dev && echo DONE\n')
self.assertEqual(rc, 0, err)
self.assertIn("DONE", out)
verbs = [c.split()[-2] if c.endswith("python3-dev") else c.split()[-1]
for c in box.called() if "apt-get" in c]
self.assertEqual(verbs, ["install", "update", "install"])
def test_apt_failing_twice_says_the_command(self):
box = Box(sudo_n=0, apt_rcs=(100, 100, 100))
rc, out, err = box.bash('host_packages "the image lane" python3-dev || echo REFUSED\n')
self.assertEqual(rc, 0, err)
self.assertIn("REFUSED", out)
self.assertIn("apt-get could not install python3-dev", err)
def test_a_lock_held_five_minutes_is_said_not_waited_for_again(self):
box = Box(sudo_n=0, apt_rcs=(100, 0, 0),
apt_err="E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 1234 (unattended-upgr)")
rc, out, err = box.bash('host_packages "the image lane" python3-dev || echo REFUSED\n')
self.assertEqual(rc, 0, err)
self.assertIn("REFUSED", out)
self.assertIn("another package manager held apt's lock", err)
self.assertEqual(len([c for c in box.called() if "apt-get" in c]), 1, "the lock was waited for again")
def test_a_sudo_that_refuses_the_password_is_not_asked_again(self):
box = Box(sudo_n=0, apt_rcs=(1, 0, 0), apt_err="sudo: 3 incorrect password attempts")
rc, out, err = box.bash('host_packages "the image lane" python3-dev || echo REFUSED\n')
self.assertEqual(rc, 0, err)
self.assertIn("REFUSED", out)
self.assertIn("sudo refused", err)
self.assertEqual(len([c for c in box.called() if "apt-get" in c]), 1, "sudo was asked again")
def test_sudo_in_french_is_read_as_well(self):
# sudo speaks the account's language (this box: fr_FR); host_packages reads it in English
box = Box(sudo_n=0, apt_rcs=(1, 0, 0), apt_err="sudo: 3 incorrect password attempts",
apt_err_fr="sudo: 3 saisies de mots de passe incorrectes")
rc, out, err = box.bash('host_packages "the image lane" python3-dev || echo REFUSED\n', LANG="fr_FR.UTF-8")
self.assertEqual(rc, 0, err)
self.assertIn("REFUSED", out)
self.assertIn("sudo refused", err)
self.assertEqual(len([c for c in box.called() if "apt-get" in c]), 1, "sudo was asked again")
def test_a_french_refusal_of_the_variables_is_retried_without_them(self):
box = Box(sudo_n=0, sudo_refuses_env=True, apt_rcs=(0,))
rc, out, err = box.bash('host_packages "the image lane" python3-dev && echo DONE\n', LANG="fr_FR.UTF-8")
self.assertEqual(rc, 0, err)
self.assertIn("DONE", out)
def test_an_account_sudo_may_not_run_apt_for_is_not_asked_again(self):
box = Box(sudo_n=0, apt_rcs=(1, 0, 0),
apt_err="Sorry, user alice is not allowed to execute '/usr/bin/apt-get install' as root on gx10.")
rc, out, err = box.bash('host_packages "the image lane" python3-dev || echo REFUSED\n')
self.assertEqual(rc, 0, err)
self.assertIn("REFUSED", out)
self.assertEqual(len([c for c in box.called() if "apt-get" in c]), 1)
def test_once_per_run(self):
# install.sh tried: the lanes' installers it calls do not wait on apt again
box = Box(sudo_n=0, apt_rcs=(100, 100, 100, 0))
rc, out, err = box.bash('host_packages "the image and video lanes" python3-dev || true\n'
'host_packages "the image lane" python3-dev || echo SKIPPED\n')
self.assertEqual(rc, 0, err)
self.assertIn("SKIPPED", out)
self.assertEqual(len([c for c in box.called() if "apt-get" in c]), 3)
def test_nothing_missing_nothing_asked(self):
box = Box(sudo_n=0)
rc, out, err = box.bash('host_packages "the image lane" && echo DONE\n')
self.assertEqual(rc, 0, err)
self.assertEqual(out.strip(), "DONE")
self.assertEqual(box.called(), [])
def block(text, start, end_line):
"""The lines of text from the one starting with `start` to the one holding `end_line`."""
a = text.index(start)
b = text.index("\n", text.index(end_line, a)) + 1
return text[a:b]
class InstallShPutsThemInBeforeTheCockpitNeedsThem(unittest.TestCase):
"""The packages step of install.sh, run as written: python3 says where its headers are (a
folder without them here), and PATH has no ffmpeg."""
TEXT = (REPO / "install.sh").read_text()
def step(self):
return block(self.TEXT, "HOST_PKGS=()\n# --no-start and --no-service",
'|| host_packages "the image and video lanes" "${HOST_PKGS[@]}" || true')
def run_step(self, want_image, want_video, headers, no_start=0, no_service=0):
box = Box(sudo_n=0)
inc = box.d / "include"
inc.mkdir()
if headers:
(inc / "Python.h").write_text("/* */\n")
(box.bin / "python3").write_text(f'#!/bin/bash\ncase "$*" in *sysconfig*) echo "{inc}" ;; esac\nexit 0\n')
(box.bin / "python3").chmod(0o755)
rc, out, err = box.bash(f"WANT_IMAGE={want_image}; WANT_VIDEO={want_video}; "
f"NO_START={no_start}; NO_SERVICE={no_service}\n" + self.step())
self.assertEqual(rc, 0, err)
return [c for c in box.called() if "apt-get" in c]
def test_a_new_box_gets_both(self):
apt = self.run_step(1, 1, headers=False)
self.assertEqual(len(apt), 1, apt)
self.assertTrue(apt[0].endswith("install python3-dev ffmpeg"), apt)
def test_the_image_lane_alone_needs_no_ffmpeg(self):
apt = self.run_step(1, 0, headers=False)
self.assertTrue(apt[0].endswith("install python3-dev"), apt)
def test_a_box_that_has_them_is_asked_nothing(self):
self.assertEqual(self.run_step(1, 0, headers=True), [])
def test_no_image_or_video_lane_asks_nothing(self):
self.assertEqual(self.run_step(0, 0, headers=False), [])
def test_no_start_and_no_service_ask_nothing(self):
# both return before those lanes; --no-service uses no sudo at all
self.assertEqual(self.run_step(1, 1, headers=False, no_start=1), [])
self.assertEqual(self.run_step(1, 1, headers=False, no_service=1), [])
def test_it_comes_after_the_ticket_and_before_the_first_download(self):
t = self.TEXT
at = t.index('host_packages "the image and video lanes"')
self.assertLess(t.index('sudo -v || die "sudo could not be used here'), at)
self.assertLess(at, t.index('step "2/10'))
class TheLanesInstallersPutThemInFromATerminal(unittest.TestCase):
def test_each_tries_before_its_own_check_which_stays(self):
for f, pkgs, check in (
("install-image.sh", ("python3-venv", "python3-dev"), 'Python.h" ] || die "python3-dev is missing'),
("install-video.sh", ("ffmpeg", "python3-venv", "python3-dev"), 'command -v ffmpeg >/dev/null || die'),
("install-speech.sh", ("ffmpeg", "python3-venv", "build-essential"), 'command -v ffmpeg >/dev/null || die')):
with self.subTest(f):
text = (REPO / f).read_text()
at = text.index("|| host_packages ")
self.assertLess(at, text.index(check), "the attempt must come before the check")
for p in pkgs:
self.assertIn(f"HOST_PKGS+=({p})" if p != "build-essential" else "c++:build-essential",
text[:at])
class TheScriptsRunFromATerminalGoOnWithTheGroup(unittest.TestCase):
def test_each_asks_before_its_first_docker_command(self):
for f in ("switch-model.sh", "install-image.sh", "install-video.sh", "install-kolibri.sh",
"install-nemotron.sh", "install-nemotron-super.sh", "install-flash-local.sh",
"uninstall.sh", "install.sh"):
with self.subTest(f):
text = (REPO / f).read_text()
at = text.index('docker_session bash "$')
self.assertIn('/${BASH_SOURCE[0]##*/}" "$@"', text[at:text.index("\n", at)])
code = [ln for ln in text[:at].splitlines() if not ln.lstrip().startswith("#")]
first = [ln for ln in code if ln.lstrip().startswith("docker ")]
self.assertEqual(first, [], f"docker is run before the group is asked for: {first}")
def test_each_has_the_die_the_library_calls(self):
for f in ("switch-model.sh", "install-image.sh", "install-video.sh", "install-kolibri.sh",
"install-nemotron.sh", "install-nemotron-super.sh", "install-flash-local.sh",
"uninstall.sh", "install.sh", "prepare-lane.sh", "install-speech.sh"):
with self.subTest(f):
text = (REPO / f).read_text()
self.assertRegex(text[:text.index('lanes.sh"')], r"\ndie ?\(\) *\{")
def test_prepare_lane_asks_where_it_loads_the_library(self):
text = (REPO / "prepare-lane.sh").read_text()
self.assertIn('. "$HERE/lanes.sh"\n # a terminal opened before', text)
def walled_with_memory(at=None, after=False):
"""walled() install.sh, its /proc/meminfo a file of a 128 GB box (the CI's runner has 16)."""
path = pathlib.Path(wall.walled(at=at, after=after))
mem = path.parent / "meminfo"
mem.write_text(MEMINFO)
path.write_text(path.read_text().replace("/proc/meminfo", str(mem)))
return str(path)
def box_for_step_1(**kw):
box = Box(**kw)
for name, body in (("uname", 'case "$1" in -m) echo aarch64 ;; *) exec /usr/bin/uname "$@" ;; esac\n'),
("nvidia-smi", 'echo "NVIDIA GB10"\n')):
(box.bin / name).write_text("#!/bin/bash\n" + body)
(box.bin / name).chmod(0o755)
return box
# the wall goes after the docker step, and after the line that gives the screen back to a run
# started again by it
GRANT_LINE = '[ -z "$DOCKER_SAID" ] || exec 1>&3 3>&-\n'
class TheWholeScripts(unittest.TestCase):
"""install.sh, get.sh and uninstall.sh run as written, up to a wall."""
def run_install(self, box, copy, *args, **extra):
env, record = wall.fenced_env(first=str(box.bin), **extra)
r = subprocess.run(["bash", copy, *args], capture_output=True, text=True, env=env,
cwd=wall.cwd(), timeout=60, stdin=subprocess.DEVNULL, start_new_session=True)
return r, r.stdout + r.stderr, record
def test_install_sh_a_terminal_older_than_the_group_relaunches_before_printing(self):
box = Box(member=True)
r, out, record = self.run_install(box, wall.walled(), "--no-video")
self.assertNotIn(wall.WALL, out)
self.assertEqual(r.returncode, 0, out[-800:])
self.assertTrue(out.lstrip().startswith("Docker: alice is in the docker group"), out[:300])
sg, = box.sg_calls()
self.assertRegex(sg, r"/install\.sh --no-video'\]$")
self.assertEqual(wall.reached(record), [])
def test_install_sh_step_1_adds_the_account_then_starts_again(self):
box = box_for_step_1()
r, out, record = self.run_install(box, walled_with_memory(at=GRANT_LINE, after=True))
self.assertNotIn(wall.WALL, out, "the run went past the docker step without the group")
self.assertEqual(r.returncode, 0, out[-800:])
self.assertIn("sudo usermod -aG docker alice", box.sudo_calls())
self.assertIn("is in the docker group now; this run goes on with it", out)
self.assertEqual(len(box.sg_calls()), 1)
def test_install_sh_with_no_service_says_how_and_uses_no_sudo(self):
box = box_for_step_1()
r, out, record = self.run_install(box, walled_with_memory(at=GRANT_LINE, after=True), "--no-service")
self.assertEqual(r.returncode, 1, out[-800:])
self.assertIn("this run uses no sudo", out)
self.assertEqual(box.sudo_calls(), [])
def test_install_sh_asks_nothing_before_its_refusals(self):
# --help, --plan and a mistyped flag end before step 1; a box below the memory refusal
# ends before the docker step: none of them may add the account to the group
for args in (("--help",), ("--plan",), ("--bogus-flag",)):
with self.subTest(args):
box = box_for_step_1()
r, out, record = self.run_install(box, walled_with_memory(at=GRANT_LINE, after=True), *args)
self.assertEqual(box.sudo_calls(), [], out[-500:])
self.assertFalse(box.sg_calls())
box = box_for_step_1()
copy = pathlib.Path(wall.walled(at=GRANT_LINE, after=True))
small = copy.parent / "meminfo-64"
small.write_text("MemTotal: 65536000 kB\n")
copy.write_text(copy.read_text().replace("/proc/meminfo", str(small)))
r, out, record = self.run_install(box, str(copy))
self.assertIn("This config needs a ~121 GB unified-memory machine", out)
self.assertEqual(box.sudo_calls(), [])
def test_install_sh_started_again_does_not_say_its_first_lines_twice(self):
box = box_for_step_1(docker_err="", docker_rc=0, member=True, in_session=True)
r, out, record = self.run_install(box, walled_with_memory(at=GRANT_LINE, after=True),
QWEN38_DOCKER_RELAUNCHED="granted")
self.assertIn(wall.WALL, r.stdout, "the screen did not come back after the docker step")
for said_before in ("Context mode", "1/10 Preflight checks", "GPU: NVIDIA GB10"):
self.assertNotIn(said_before, r.stdout)
def test_get_sh_leaves_the_docker_step_to_install_sh(self):
box = Box()
clone = box.d / "clone"
clone.mkdir()
(clone / ".git").mkdir()
(box.bin / "git").write_text(
"#!/bin/bash\n"
'case "$*" in\n'
' *"remote get-url origin"*) echo https://github.com/hasso5703/dgx-spark-qwen38 ;;\n'
' *"symbolic-ref"*) echo main ;;\n'
' *"rev-list --count"*) echo 0 ;;\n'
' *"log -1"*) echo "abc1234 the release" ;;\n'
'esac\nexit 0\n')
(box.bin / "git").chmod(0o755)
env, record = wall.fenced_env(first=str(box.bin), DIR=str(clone))
r = subprocess.run(["bash", wall.walled("get.sh", at=' exec bash ./install.sh "$@"\n'), "--help"],
capture_output=True, text=True, env=env, cwd=wall.cwd(), timeout=60,
stdin=subprocess.DEVNULL, start_new_session=True)
out = r.stdout + r.stderr
self.assertIn(wall.WALL, out, "get.sh did not go on to install.sh")
self.assertEqual(box.sudo_calls(), [], "get.sh asked sudo before install.sh read its flags")
self.assertFalse([c for c in box.called() if c.startswith("docker")])
def test_uninstall_sh_says_the_way_out_when_it_cannot_start_again(self):
box = Box(member=True, with_sg=False)
d = box.d / "repo"
d.mkdir()
for f in ("uninstall.sh", "lanes.sh", "oc-merge-limits.py"):
(d / f).write_text((REPO / f).read_text())
r = subprocess.run(["/bin/bash", str(d / "uninstall.sh"), "--list"], capture_output=True, text=True,
env=box.env(), cwd=str(d), timeout=60,
stdin=subprocess.DEVNULL, start_new_session=True)
self.assertEqual(r.returncode, 1, r.stdout + r.stderr)
self.assertIn("Log out and back in", r.stderr)
self.assertNotIn("command not found", r.stderr)
if __name__ == "__main__":
unittest.main(verbosity=2)
+15 -3
View File
@@ -20,9 +20,21 @@ class TheCockpitsRootIsStatedAsItIs(unittest.TestCase):
self.assertNotIn("reaches root through exactly one", FLAT)
def test_the_docker_group_is_named_while_install_sh_requires_it(self):
if "usermod -aG docker" in (REPO / "install.sh").read_text():
self.assertIn("`docker` group", FLAT)
self.assertIn("root-equivalent", FLAT)
# install.sh reaches docker through lanes.sh (docker_grant) since v1.37.2: the check
# reads both, or it would have stopped checking without a word when the line moved
code = (REPO / "install.sh").read_text() + (REPO / "lanes.sh").read_text()
self.assertIn("docker_grant", (REPO / "install.sh").read_text())
self.assertIn("usermod -aG docker", code)
self.assertIn("`docker` group", FLAT)
self.assertIn("root-equivalent", FLAT)
def test_the_page_says_the_installer_adds_the_account(self):
# it adds the account itself on a box whose first-boot setup left it out (v1.37.2)
if "sudo usermod -aG docker" in (REPO / "lanes.sh").read_text():
self.assertIn("adds it to that group when it is not in it", FLAT)
self.assertIn("before it runs sudo", FLAT)
# and not a promise of a password prompt that a sudo ticket skips (found in review)
self.assertIn("does not ask while an earlier ticket is still valid", FLAT)
def test_the_staged_unit_install_is_named_while_the_allowlist_has_it(self):
sudoers = (REPO / "dashboard" / "sudoers-cockpit.template").read_text()
+2
View File
@@ -43,6 +43,8 @@ class Box:
self.script = self.d / "uninstall.sh"
self.script.write_text(text)
(self.d / "oc-merge-limits.py").write_text((REPO / "oc-merge-limits.py").read_text())
# the library it sources since v1.37.2, for the docker group of a terminal older than it
(self.d / "lanes.sh").write_text((REPO / "lanes.sh").read_text())
stub = self.d / "bin"
stub.mkdir()
log = self.d / "calls"
+7
View File
@@ -57,6 +57,13 @@ for arg in "${@:-}"; do
*) echo "Unknown flag: $arg (see --help)" >&2; exit 1 ;;
esac
done
# A terminal opened before the account joined the docker group sees none of its images: the
# inventory below skipped them all (docker info failed) and left them on the disk. It goes on
# with the group (lanes.sh).
die(){ printf '\n\033[1;31mERROR:\033[0m %s\n' "$*" >&2; exit 1; }
# shellcheck source=lanes.sh
. "$REPO_DIR/lanes.sh"
docker_session bash "$REPO_DIR/${BASH_SOURCE[0]##*/}" "$@"
# ── Inventory: every name this repo has ever created, shown only if present ──
# Local serving images built by install.sh across versions (any tag: v1.2,