summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2025-12-01 06:15:51 -0600
committerCraig Jennings <c@cjennings.net>2025-12-01 06:15:51 -0600
commit75b0a17576f2722611db3ce710e673e0445848cf (patch)
tree90c42acf5493e07702a601a79794f40e1907091a
parent03145a135d854f9aceb82ad65ce47a6a39235094 (diff)
feat(archsetup): add pre-flight checks before installation
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 <noreply@anthropic.com>
-rw-r--r--TODO.org10
-rwxr-xr-xarchsetup49
2 files changed, 57 insertions, 2 deletions
diff --git a/TODO.org b/TODO.org
index cf33cea..9067d6d 100644
--- a/TODO.org
+++ b/TODO.org
@@ -159,8 +159,14 @@ Could destroy user's uncommitted changes in repos during dotfile setup
RESOLVED: Already fixed - git_install and yay installer use safe rm + fresh clone approach.
No git pull --force in current script.
-*** TODO [#A] Add pre-flight checks before installation starts
-Validate system requirements: disk space, network connectivity, Arch version, tool dependencies (curl, stow, git, make)
+*** DONE [#A] Add pre-flight checks before installation starts
+CLOSED: [2025-12-01 Sun]
+Validate system requirements: disk space, network connectivity, Arch version, tool dependencies
+RESOLVED: Added preflight_checks() function that verifies:
+- Disk space (minimum 20GB free)
+- Network connectivity (ping archlinux.org)
+- pacman available
+- Running on Arch Linux (/etc/arch-release exists)
*** TODO [#A] Implement state tracking for install progress
Track what completed vs failed mid-run to enable targeted recovery and resume capability
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