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,