- ZRAM Scaling (docs/QUICKSTART.md): Updated Step 9 with the current fixed-4096MB formula: `≤8 GB → 50%`, `>8 GB → 4096 MB fixed`. Replaced obsolete `ram_gb > 16 ? 25% : 50%` and `/4` vs `/2` logic with the new behavior (`ram_gb <= 8 ? 50% : 4096 MB`). Examples: 4GB → 2048 MB, 8GB → 4096 MB, 16GB → 4096 MB, 32GB → 4096 MB.
- GPU Configuration (docs/gpu.md): Added AMD GCN Migration subsection with duplicate guard (`content_differs-style` check) and sed fix logic. Added Secure Boot warning for NVIDIA DKMS (`mokutil --sb-state` detection). Documented `|| return 1` protection for `/etc/modprobe.d/nvidia-wayland.conf` writing. Renumbered duplicate sections 7 → 8 → 9 to avoid duplicate headings.
- Firmware Installation (docs/firmware.md): Updated Broadcom section with `_run_cmd` wrappers (`|| true`) for `apt install broadcom-sta-dkms` and `modprobe wl`. Added SSH network warning (`WARNING: SSH is not recommended on a router`) before `modprobe -r`. Updated Initramfs step with `_run_cmd` wrapper (`|| true`).
- Repo Configuration (docs/repos_config.md): Removed `REPOS_CONFIGURED=true` from the POST-EXECUTION PHASE diagram and Safety Mechanisms. Added `_write_branch_sources` with its `_restore_backup` rollback and "Branch Migration Rollback" safety note to the diagram.
- System Info & Pre-flight (docs/system_info.md): Added pre-flight init (auto-install whiptail + lsb-release). Added LSPCI_OUTPUT cache with `command -v lspci` guard. Added `_ensure_apt_updated` deduplication helper. Added `STATE_REFRESHED=true` flag mechanism across all menu branches.
- User Home Ownership (docs/user_priv_feed.md): Updated Option 3 (Repair Home Ownership) to use `getent passwd "${SUDO_USER:-$USER}"` instead of the insecure `eval echo "~$USER"` pattern. Added documentation note explaining the security rationale.
- QuickStart ZRAM (docs/QUICKSTART.md): Updated Step 9 ZRAM scaling to "50% of RAM (≤8 GB) or 4096 MB fixed (>8 GB)".
7.1 KiB
Option 1: Hardware Detection & System Information
1. What Does This Component Do?
This component serves as the System Abstraction Layer and diagnostic engine of the Debianito script. It is not merely a display utility; it acts as the foundational state initializer that runs prior to the main menu loop (main_menu). Its primary function is to perform pre-flight hardware enumeration, OS validation, and environment checks in "cold" mode (before any configuration changes are made).
Pre-flight initialization (debianito.sh startup sequence):
- Dependency auto-install: The script checks for
whiptailandlsb-release, installing them automatically if missing — ensuring the TUI and version detection work on minimal systems. lspciguard and cache:command -v lspci &>/dev/nullvalidates availability before execution. If present, the fulllspci -nnoutput is captured once into the global variableLSPCI_OUTPUT. All subsequent GPU, Ethernet, and network detection reads from this cache — avoiding redundantlspciinvocations and ensuring consistent data throughout the session.- APT update deduplication: The helper
_ensure_apt_updatedprevents redundantapt updatecalls by tracking whether the package lists have been refreshed recently. This is critical for performance when multiple modules (repos, firmware, GPU, kernel) each need to verify repository state. - State refresh flag:
STATE_REFRESHED=trueis set before;;in everycasebranch of the main menu loop, ensuring that each menu entry starts with a clean, consistent state rather than stale cached data.
By populating global variables such as DEBIAN_VERSION, GPU_TYPE, CPU_SUMMARY, and network interface states, it ensures that the subsequent menu options have access to accurate context. This prevents the user from making blind decisions—for example, attempting to install proprietary drivers on a system without detected hardware or selecting repositories incompatible with the current Debian codename. It transforms raw kernel data into actionable configuration parameters.
2. System Commands Used (Technical Mapping)
The following table details the native Linux tools and file descriptors utilized by utils.sh to extract specific diagnostic data points. This mapping demonstrates reliance on standard, non-intrusive system utilities rather than proprietary binaries.
| Feature | Command / Tool | Technical Purpose & Logic |
|---|---|---|
| OS Version | lsb_release -cs, /etc/os-release |
Parses VERSION_CODENAME to determine Debian release (Bullseye, Bookworm, Trixie). Critical for selecting correct repository backports. |
| CPU Info | /proc/cpuinfo |
Reads model name and counts cores/threads. Provides cosmetic summary without needing heavy tools like lscpu. |
| Memory | /proc/meminfo |
Extracts MemTotal to calculate RAM in GB. Used for compatibility warnings with specific software packages. |
| GPU Detection | command -v lspci guard → cached LSPCI_OUTPUT |
lspci -nn output is cached in the global variable LSPCI_OUTPUT at startup. All subsequent GPU detection (PCI/USB buses, Ethernet, network) reads from this cache instead of re-running lspci. Identifies VGA/3D controllers via PCI IDs (10de for NVIDIA). Checks driver versions via dpkg if nvidia-smi fails. |
| Network (Eth) | ip -o link show |
Enumerates Ethernet interfaces, state (UP/DOWN), and IP addresses using the iproute2 suite. |
| Network (Wi-Fi) | iwgetid, lspci |
Identifies wireless chipsets via PCI and retrieves SSID/Connection status for network diagnostics. |
| Storage | lsblk -d -o NAME,SIZE,ROTA |
Distinguishes between NVMe (nvme), SSD (RoT=0), and HDD (RoT=1) to provide storage topology summary. |
| Display Server | Environment Vars (XDG_SESSION_TYPE) |
Checks WAYLAND_DISPLAY vs DISPLAY variables to determine if the system is running Wayland, X11, or TTY. |
3. Strategic Importance for the Script
This diagnostic phase is vital for engineering stability and user experience (UX) integrity within the script architecture:
- Context-Aware Configuration: The detection of
HAS_NVIDIA,HAS_AMD, orHAS_INTELdirectly dictates which sub-modules are loaded indebianito.sh. If no GPU is detected, graphics driver menus are skipped. This prevents "false positive" installation prompts that confuse the user. - Repository Compatibility Guardrails: The
detect_debian_versionfunction validates the OS against supported codenames (11, 12, 13). It specifically triggers Bullseye-specific logic (configure_repos_bullseye) only when necessary, preventing repository errors on newer or older distributions. - APT Update Deduplication: The
_ensure_apt_updatedhelper tracks whetherapt updatehas been run recently. Multiple modules (repos, firmware, GPU, kernel) share a single update cycle, preventing redundant network calls and inconsistent package state between modules. - State Refresh Consistency:
STATE_REFRESHED=trueis set before;;in everycasebranch of the main menu loop, ensuring each menu entry starts with a clean state and preventing stale variable propagation between sequential selections. - Time Synchronization Safety: The
check_system_timefunction prevents package installation failures caused by clock skew (which breaks GPG signatures in APT). By offering an automated NTP sync before proceeding, it ensures the integrity of the entire software supply chain within the script. - Root/Sudo Enforcement: Early execution of
check_rootandcheck_sudoenforces security best practices. It prevents accidental privilege escalation or silent failures that often occur when scripts run with incorrect permissions.
4. Formatting and UX in the Terminal
The raw data collected by these functions is processed into a human-readable format before being passed to the TUI (Text User Interface) via whiptail.
- Structured String Assembly: Functions like
_show_sysinfobuild multi-line strings (msg+="..."), appending newlines and conditional logic. This ensures that if multiple GPUs are found, they are listed sequentially with drivers identified below each entry. - Visual Hierarchy: The data is organized into logical blocks (OS, Hardware, GPU, Network) with clear separators (
───). This allows the user to quickly scan specific subsystems without scrolling through a monolithic log. - Conditional Rendering: The script checks for command availability (e.g.,
if ! command -v lspci &>/dev/nullguards GPU detection,if ! command -v ip &>/dev/nullguards network data). If tools are missing, it gracefully degrades to a warning message rather than crashing the TUI. Whenlspciis present, its output is cached inLSPCI_OUTPUTfor all subsequent detection calls. - TUI Integration: The final formatted string is passed to
_msg, which wraps the output in awhiptail --msgbox. This ensures the diagnostic information appears as a modal dialog with consistent dimensions and styling (colors defined globally indebianito.sh), maintaining a professional look regardless of the underlying terminal emulator.