From bcbcc3392dae85174358e1c48ed75b5e8bc62bf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Thu, 30 Apr 2026 13:06:49 +0200 Subject: [PATCH] install.sh: offer to install missing tools via dnf Instead of dying immediately, check_tools now lists missing packages, asks the user to install them with dnf, and re-verifies after install. Decline still aborts as before. Co-Authored-By: Claude Sonnet 4.6 --- system_setup/install.sh | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/system_setup/install.sh b/system_setup/install.sh index 30689dc..4f68c3d 100755 --- a/system_setup/install.sh +++ b/system_setup/install.sh @@ -28,11 +28,37 @@ require_root() { } check_tools() { + declare -A tool_pkg=( + [lsblk]="util-linux" [blkid]="util-linux" + [parted]="parted" [partprobe]="parted" + [mkfs.btrfs]="btrfs-progs" [git]="git" + [e2fsck]="e2fsprogs" [resize2fs]="e2fsprogs" + [tune2fs]="e2fsprogs" + ) local missing=() for tool in lsblk blkid parted partprobe mkfs.btrfs git e2fsck resize2fs tune2fs; do command -v "$tool" >/dev/null 2>&1 || missing+=("$tool") done - [[ ${#missing[@]} -eq 0 ]] || die "Missing required tools: ${missing[*]}" + [[ ${#missing[@]} -eq 0 ]] && return 0 + + echo "Missing required tools: ${missing[*]}" + local pkgs=() + for tool in "${missing[@]}"; do + local pkg="${tool_pkg[$tool]}" + [[ " ${pkgs[*]} " != *" $pkg "* ]] && pkgs+=("$pkg") + done + + read -r -p " Install missing packages (${pkgs[*]}) with dnf? [y/N]: " ans + if [[ "${ans,,}" == "y" ]]; then + dnf install -y "${pkgs[@]}" || die "Package installation failed." + local still_missing=() + for tool in "${missing[@]}"; do + command -v "$tool" >/dev/null 2>&1 || still_missing+=("$tool") + done + [[ ${#still_missing[@]} -eq 0 ]] || die "Still missing after install: ${still_missing[*]}" + else + die "Missing required tools: ${missing[*]}" + fi } # Returns 0 if the remote install.sh matches this script's checksum,