#!/usr/bin/env bash # =========================================================================== # Stage 00: Environment Checks # Verifies we can proceed: distro detected, sudo available, dirs exist. # Distro detection is handled by lib/distro.sh (sourced by provision.sh). # =========================================================================== info "Distribution: ${DISTRO_ID} ${DISTRO_VERSION} (${DISTRO_FAMILY} family)" info "Package manager: ${PKG_MGR}" # ---- Sudo access ---- info "Checking sudo access..." if ! sudo -n true 2>/dev/null; then info "Sudo access required. You may be prompted for your password." sudo -v || { error "Sudo required for provisioning."; exit 1; } fi ok "Sudo access confirmed." # Keep sudo timestamp fresh while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & # ---- Directory structure ---- info "Setting up directory structure..." mkdir -p "$HOME/Development" "$HOME/.local/bin" "$HOME/.config" "$HOME/.local/share" ok "Directory structure ready." # ---- Internet check ---- info "Checking internet connectivity..." if ! ping -c 1 -W 3 google.com &>/dev/null && ! ping -c 1 -W 3 github.com &>/dev/null; then warn "No internet detected. Some steps may fail." else ok "Internet connectivity confirmed." fi # ---- Package cache update (first time) ---- info "Updating package cache (first run)..." $PKG_UPDATE 2>/dev/null || warn "Package cache update had issues." # ---- System upgrade ---- info "Upgrading all system packages..." $PKG_UPGRADE 2>/dev/null || warn "System upgrade had issues (this is okay on a fresh install)." ok "Stage 00 complete."