Thomas Stallinger cd91a6b393 feat: run installer.sh automatically inside the live session
Uses dracut's official 20-apply-live-updates.sh pre-pivot hook: any
/updates/ directory tree present at the top level of the boot media
gets copied into the live root filesystem before pivoting, verbatim,
no initrd or squashfs/EROFS modification needed. build.sh assembles
this tree from scripts/, backends/, config/ (mapped under
/opt/tuxflotte) plus live-updates/etc/ (an XDG autostart entry that
opens a terminal running installer.sh as root, and a sudoers.d drop-in
granting liveuser passwordless sudo).

xorriso preserves the ownership/permissions recorded at map time, so
-chown_r/-chgrp_r 0 on /updates is enough to make sudoers accept the
drop-in as root-owned without needing local root to build the ISO.

This was tried first as a direct EROFS unpack/repack of
/LiveOS/squashfs.img (that file is actually EROFS despite the name on
current Fedora), but a fresh self-built erofs-utils (Debian's
packaged 1.5-1 can't even read this image's on-disk format) hit a
reproducible bug extracting the packed/fragmented inode into a single
corrupt file instead of a directory tree. The dracut hook sidesteps
that path entirely.

Verified end-to-end: booting either Tuxflotte entry reaches the
Cinnamon live desktop, autostarts a terminal, and installer.sh runs
through every module (network, hardware, enrollment, handshake,
device status, Bereitstellungsvorlage selection, commit point, Runtime
Blueprint resolution against the real server, full Fedora backend
lifecycle, storage detection) to a clean exit.
2026-07-20 14:52:05 +02:00

120 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SOURCE_ISO="${1:-}"
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
BASE_DIR="$(cd "$REPO_DIR/.." && pwd)"
BUILD_DIR="$BASE_DIR/build"
WORK_DIR="$BUILD_DIR/work"
OUTPUT_DIR="$BUILD_DIR/output"
usage() {
echo "Usage: $0 /path/to/source.iso"
}
check_input() {
if [[ -z "$SOURCE_ISO" ]]; then
usage
exit 1
fi
if [[ ! -f "$SOURCE_ISO" ]]; then
echo "Error: ISO not found: $SOURCE_ISO"
exit 1
fi
}
check_dependencies() {
for cmd in xorriso; do
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "Error: missing dependency: $cmd"
exit 1
fi
done
}
prepare_dirs() {
mkdir -p "$BUILD_DIR" "$OUTPUT_DIR"
rm -rf "$WORK_DIR"
mkdir -p "$WORK_DIR"
}
extract_iso() {
echo "Extracting ISO..."
xorriso -indev "$SOURCE_ISO" -osirrox on -extract / "$WORK_DIR" >/dev/null
}
patch_grub() {
echo "Installing Tuxflotte GRUB configuration..."
cp "$REPO_DIR/grub/EFI-BOOT-grub.cfg" \
"$WORK_DIR/EFI/BOOT/grub.cfg"
cp "$REPO_DIR/grub/boot-grub2-grub.cfg" \
"$WORK_DIR/boot/grub2/grub.cfg"
}
verify_workdir() {
echo "Verifying workdir..."
grep -q "Tuxflotte" "$WORK_DIR/EFI/BOOT/grub.cfg"
grep -q "Tuxflotte" "$WORK_DIR/boot/grub2/grub.cfg"
echo "GRUB verification passed."
}
prepare_updates() {
echo "Assembling live-updates payload..."
local updates_dir="$WORK_DIR/updates"
rm -rf "$updates_dir"
mkdir -p "$updates_dir/opt/tuxflotte"
cp -a "$REPO_DIR/live-updates/etc" "$updates_dir/"
cp -a "$REPO_DIR/scripts" "$updates_dir/opt/tuxflotte/"
cp -a "$REPO_DIR/backends" "$updates_dir/opt/tuxflotte/"
cp -a "$REPO_DIR/config" "$updates_dir/opt/tuxflotte/"
chmod 0440 "$updates_dir/etc/sudoers.d/90-tuxflotte"
}
create_iso() {
echo "Creating Tuxflotte ISO..."
local output_iso="$OUTPUT_DIR/tuxflotte-provisioning-0.2.iso"
rm -f "$output_iso"
xorriso \
-indev "$SOURCE_ISO" \
-outdev "$output_iso" \
-compliance no_emul_toc \
-map "$REPO_DIR/grub/EFI-BOOT-grub.cfg" /EFI/BOOT/grub.cfg \
-map "$REPO_DIR/grub/boot-grub2-grub.cfg" /boot/grub2/grub.cfg \
-map "$WORK_DIR/updates" /updates \
-chown_r 0 /updates -- \
-chgrp_r 0 /updates -- \
-boot_image any replay
echo "ISO created: $output_iso"
}
main() {
check_input
check_dependencies
prepare_dirs
extract_iso
patch_grub
verify_workdir
prepare_updates
create_iso
echo
echo "Build complete."
echo "Work dir: $WORK_DIR"
}
main "$@"