Files
debianito-post-install/modules/gaming.sh
T
stornic56 a91b0caa25 critical-fixes, swap module & gaming overhaul
- Fixed script crashes from `whiptail` Cancel/Esc under `set -e`. Added `_menu()`, `_checklist()` and `_inputbox()` wrappers with `|| true` to prevent premature exits.
- Resolved startup failures by using defaults instead of relying on unset variables with `set -u`.
- Hardened sudoers management — `_validate_sudoers()` writes to temp file, validates with `visudo -cf`, only copies if successful.
- Replaced `eval` in `_run_cmd` with safer `bash -c` execution.

Swap Management Module (`modules/swap.sh`)
- New standalone module with 9 internal functions and `manage_swap()` entry point.
- Btrfs CoW detection — applies `chattr +C` before swapfile creation to prevent mkswap rejection on Btrfs.
- Dynamic swappiness configuration — reads current system value instead of hardcoding 60, pre-fills inputbox with existing setting.
- Uses `/run/lock/debianito-swap.lock` for early init compatibility (added as option 9 in main menu).

Repository & Branch Migration (`modules/repos/migrate.sh`)
- Handles branch migration from stable (11/12) to Testing or SID with 5-screen UX flow.
- Persistent backup system — creates timestamped tar.gz backups of `/etc/apt/sources.list*`, auto-restores on apt update failure.
- SID guardrails — installs `apt-listbugs` and `apt-listchanges` before upgrade to warn about critical bugs in unstable packages.
- Dynamic menu options based on Debian version (SID shows only 1-2-3 Exit, non-SID includes backports + branch migration).
- New `_components_enabled()` helper detects current contrib/non-free state.

Gaming Module Overhaul
- Unified gaming checklist — merged i386 toggle into single prompt with lazy evaluation instead of separate pre-check.
- Lazy 32-bit architecture enablement — only enables i386 when needed (steam/lutris/i386 selected) and installs graphics drivers if `need_32bit=true`.
- New `_install_nvidia_32bit()` helper with proper driver detection, version pinning, and legacy/tesla variant handling.

Heroic & OpenRGB Downloads
- Heroic — fetches latest release from GitHub API using `jq` to extract amd64.deb URL, validates with `dpkg-deb --info`.
- OpenRGB — downloads from Codeberg Gitea API with SHA256 verification when available, fallback to `dpkg-deb` validation.
- Dynamic codename detection — now detects Bookworm vs Trixie at runtime instead of hardcoded static values for .deb download URLs.

|Other Improvements
- Renumbered main menu: 8=ZRAM, 9=Swap Management, 10=Extras, 11=Boot Rescue, 12=Exit.
- Improved `detect_storage()` — excludes loop/CD-ROM devices via `lsblk -e 7,11`, explicitly skips zram, detects USB/SD via `/sys/block/$name/removable`.
- Standardized SCROLL_HINT across all files with centralized readonly variable.
2026-07-10 01:42:57 -05:00

136 lines
4.6 KiB
Bash

#!/usr/bin/env bash
# Gaming dispatcher — sources submodules and provides install_gaming()
_GAMING_DIR="${MODULES_DIR}/gaming"
source "${_GAMING_DIR}/_helpers.sh"
source "${_GAMING_DIR}/steam.sh"
source "${_GAMING_DIR}/heroic.sh"
source "${_GAMING_DIR}/tools.sh"
# Check if 'contrib' component is enabled; offer to add if missing
ensure_contrib_repo() {
local contrib_found=false
if [ -f /etc/apt/sources.list ]; then
if grep -Eq '^[^#]*\bcontrib\b' /etc/apt/sources.list 2>/dev/null; then
contrib_found=true
fi
fi
if ! $contrib_found && [ -d /etc/apt/sources.list.d ]; then
if grep -qr 'Components:.*\bcontrib\b' /etc/apt/sources.list.d/*.sources 2>/dev/null; then
contrib_found=true
fi
fi
if $contrib_found; then
return 0
fi
if _confirm "contrib Repository" "Component 'contrib' is required for Steam.\n\nAdd 'contrib' to your APT repositories?"; then
if [ -f /etc/apt/sources.list ]; then
sudo sed -i '/^deb / { /contrib/! s/main/main contrib/ }' /etc/apt/sources.list
fi
if [ -d /etc/apt/sources.list.d ]; then
for f in /etc/apt/sources.list.d/*.sources; do
[ -f "$f" ] || continue
sudo sed -i '/^Components:/ { /contrib/! s/$/ contrib/ }' "$f"
done
fi
sudo apt update
echo -e "${GREEN}contrib repository enabled.${NC}"
return 0
fi
echo -e "${YELLOW}contrib repository not enabled. Steam installation may fail.${NC}"
return 1
}
install_gaming() {
echo -e "${YELLOW}Gaming setup...${NC}"
# 1. Single checklist with ALL options (including i386 toggle)
local choices
choices=$(_checklist "Gaming Setup" \
"Select gaming packages to install${SCROLL_HINT}:" $TUI_ALTO $TUI_ANCHO $TUI_ALTO_LISTA \
"steam" "Steam (requires 32-bit support)" ON \
"gamemode" "Game performance optimization" ON \
"mangohud" "Performance overlay (Vulkan/OpenGL)" ON \
"goverlay" "MangoHud config GUI" ON \
"heroic" "Heroic Launcher (Epic/GOG)" OFF \
"java" "Minecraft Java Runtime" OFF \
"openrgb" "OpenRGB (RGB lighting control)$(_inst openrgb)" OFF \
"lutris" "Lutris + Wine (requires 32-bit support)" OFF \
"retroarch" "RetroArch Emulator Frontend$(_inst retroarch)" OFF \
"i386" "Enable 32-bit (i386) architecture" ON)
if [ -z "$choices" ]; then
echo "No gaming packages selected."
_pause
return
fi
local cleaned
cleaned=$(echo "$choices" | tr -d '"')
# 2. Determine if 32-bit is needed (steam, lutris, or explicit i386 toggle)
local need_32bit=false
for p in $cleaned; do
case $p in steam|lutris) need_32bit=true ;; esac
done
echo "$cleaned" | grep -qw i386 && need_32bit=true
# Strip pseudo-entry "i386" from the install list
local install_list
install_list=$(echo "$cleaned" | tr ' ' '\n' | grep -v '^i386$' | tr '\n' ' ')
install_list=${install_list% }
# 3. Enable i386 architecture if needed
if $need_32bit && ! dpkg --print-foreign-architectures 2>/dev/null | grep -q i386; then
echo -e "${YELLOW}Enabling i386 architecture (required by selection)...${NC}"
sudo dpkg --add-architecture i386
_run_cmd "APT Update" "sudo apt update" "Updating package lists..."
fi
# 4. Install 32-bit graphics drivers only if 32-bit is needed
if $need_32bit; then
echo "Installing 32-bit graphics drivers..."
if [ "$GPU_TYPE" = "nvidia" ]; then
_install_nvidia_32bit
else
_install_mesa_32bit
fi
fi
# 5. Install selected packages
for pkg in $install_list; do
case $pkg in
steam)
if ensure_contrib_repo; then
install_steam
else
echo -e "${YELLOW}Skipping Steam installation (contrib repository not enabled).${NC}"
fi
;;
heroic) install_heroic ;;
java) install_minecraft_java ;;
mangohud) install_mangohud ;;
gamemode) install_gamemode ;;
goverlay) install_goverlay ;;
openrgb)
if [ "$DEBIAN_VERSION" = "11" ]; then
echo "OpenRGB requires Debian 12+."
continue
fi
install_openrgb
;;
lutris) install_lutris ;;
retroarch) install_retroarch ;;
*) _run_install "$pkg" ;;
esac
done
echo -e "${GREEN}Gaming setup complete.${NC}"
_pause
}