From 75b0a17576f2722611db3ce710e673e0445848cf Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 1 Dec 2025 06:15:51 -0600 Subject: feat(archsetup): add pre-flight checks before installation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Validates system requirements before starting: - Disk space (minimum 20GB free on /) - Network connectivity (ping archlinux.org) - pacman available - Running on Arch Linux (/etc/arch-release) Provides clear error messages with recovery hints if checks fail. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- archsetup | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'archsetup') diff --git a/archsetup b/archsetup index 9329a0e..585f1f5 100755 --- a/archsetup +++ b/archsetup @@ -63,6 +63,54 @@ packages_before="/var/log/archsetup-preexisting-package-list.txt" packages_after="/var/log/archsetup-post-install-package-list.txt" archsetup_packages="/var/log/archsetup-installed-packages.txt" +min_disk_space_gb=20 + +### Pre-flight Checks +preflight_checks() { + echo "Running pre-flight checks..." + + # Check disk space (need at least 20GB free on root partition) + available_kb=$(df / | awk 'NR==2 {print $4}') + available_gb=$((available_kb / 1024 / 1024)) + if [ "$available_gb" -lt "$min_disk_space_gb" ]; then + echo "ERROR: Insufficient disk space" + echo " Required: ${min_disk_space_gb}GB" + echo " Available: ${available_gb}GB" + echo " Free up disk space before running archsetup." + exit 1 + fi + echo " [OK] Disk space: ${available_gb}GB available" + + # Check network connectivity + if ! ping -c 1 -W 5 archlinux.org > /dev/null 2>&1; then + echo "ERROR: No network connectivity" + echo " Cannot reach archlinux.org" + echo " Ensure network is configured before running archsetup." + echo " Try: ip link, dhcpcd, or nmtui" + exit 1 + fi + echo " [OK] Network: archlinux.org reachable" + + # Check pacman is available + if ! command -v pacman > /dev/null 2>&1; then + echo "ERROR: pacman not found" + echo " This script requires Arch Linux with pacman installed." + exit 1 + fi + echo " [OK] Package manager: pacman available" + + # Check we're on Arch Linux + if [ ! -f /etc/arch-release ]; then + echo "ERROR: Not running on Arch Linux" + echo " This script is designed for Arch Linux only." + exit 1 + fi + echo " [OK] System: Arch Linux detected" + + echo "Pre-flight checks passed." + echo "" +} + ### Intro intro() { printf "\n\nArchSetup launched @ %s\n" "$(date +'%D %T')"| tee -a "$logfile" @@ -1045,6 +1093,7 @@ outro() { } ### Installation Steps +preflight_checks # verify system requirements before starting intro # take start stats prerequisites # install software required to install software -- cgit v1.2.3