From ec91122621fa75d030881aec46adff5d0c0c60e3 Mon Sep 17 00:00:00 2001 From: Claude Bot Date: Fri, 6 Nov 2026 09:56:55 +0100 Subject: [PATCH] fix(edge-host-iso): take the hostname as an argument in edge-install edge-install wrote a hard-coded edge-1 into /etc/hostname, so every further edge host came up with the production host's name and DHCP hostname. The hostname is now a required argument, validated as an RFC 1123 label and confirmed before the disk is wiped. Co-Authored-By: Claude Opus 5.5 --- ansible/docs/edge-host.md | 2 +- images/edge-host-iso/README.md | 9 +++++---- .../airootfs/usr/local/bin/edge-install | 14 ++++++++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/ansible/docs/edge-host.md b/ansible/docs/edge-host.md index 81dcaf9a..5c946cfc 100644 --- a/ansible/docs/edge-host.md +++ b/ansible/docs/edge-host.md @@ -29,7 +29,7 @@ Build and boot the dedicated installer image — see `images/edge-host-iso/README.md`. Short version: 1. `sudo pacman -S archiso && sudo images/edge-host-iso/build.sh` -2. Write ISO to a USB stick, boot the target box from it, run `edge-install` +2. Write ISO to a USB stick, boot the target box from it, run `edge-install ` (partitions the internal disk — NVMe if present, else the eMMC; the installer autodetects — installs the ansible-ready base system with SSH keys, DHCP, docker — asks for confirmation before wiping). diff --git a/images/edge-host-iso/README.md b/images/edge-host-iso/README.md index 3569a72d..bb79a7cb 100644 --- a/images/edge-host-iso/README.md +++ b/images/edge-host-iso/README.md @@ -42,10 +42,11 @@ for the CA key; rebuild the ISO after a CA rotation. 2. Boot the target from it (UEFI, Secure Boot off; one-time F12/setup visit if the box doesn't already boot USB first) 3. Either on the console (auto-login as root) or headless — - `ssh root@` with an owner certificate — run `edge-install`. It auto-detects the internal disk - (NVMe, else eMMC — covers the Wyse 3040 — else first non-USB disk), - shows the target and requires typing the hostname before wiping - anything. Override with `edge-install /dev/sdY`. + `ssh root@` with an owner certificate — run + `edge-install ` (e.g. `edge-install edge-2`). It auto-detects + the internal disk (NVMe, else eMMC — covers the Wyse 3040 — else first + non-USB disk), shows the target and requires typing the hostname before + wiping anything. Override with `edge-install /dev/sdY`. 4. Reboot. Confirm the box is reachable by name — `ssh root@` — before going further; it is identified by name everywhere and its address is never recorded. Then add it to `[edge_host]` in diff --git a/images/edge-host-iso/airootfs/usr/local/bin/edge-install b/images/edge-host-iso/airootfs/usr/local/bin/edge-install index 52f18558..51debb6e 100755 --- a/images/edge-host-iso/airootfs/usr/local/bin/edge-install +++ b/images/edge-host-iso/airootfs/usr/local/bin/edge-install @@ -1,13 +1,19 @@ #!/usr/bin/env bash -# Installer for edge-1 (bare-metal edge host, replaces the k8s-edge VM). +# Installer for the bare-metal edge hosts (edge-1, edge-2, ...). # Runs from the edge-host ISO live environment. WIPES the target disk. -# Usage: edge-install [disk] -# Default: the internal disk — first NVMe, else eMMC (Wyse 3040), else +# Usage: edge-install [disk] +# Default disk: the internal disk — first NVMe, else eMMC (Wyse 3040), else # the first non-USB, non-optical disk. The live USB stick itself is # excluded via the ISO9660 label mount. set -euo pipefail -HOST=edge-1 +usage() { echo "usage: edge-install [disk]"; exit 1; } +[ $# -ge 1 ] && [ $# -le 2 ] || usage +HOST=$1 +# RFC 1123 label: what systemd-networkd sends as the DHCP hostname. +[[ "$HOST" =~ ^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$ ]] \ + || { echo "invalid hostname: $HOST"; exit 1; } +shift detect_disk() { # eMMC needs mmc_block before any /dev/mmcblk* exists (see -- 2.54.0