mirror of
https://github.com/stornic56/debianito-post-install.git
synced 2026-10-31 13:08:06 +00:00
9a96dff6ea
- Verified the repository backup rc in migrate.sh. `_persistent_backup_repos()` now aborts before any destructive step when the tar archive is missing or corrupt, removing the invalid backup itself. - Verified the restore rc in migrate.sh. `_restore_backup()` now reports failure instead of printing a green "Backup restored" message, and its caller distinguishes a restored backup from a failed restore. - Made the upgrade phases fail honestly. `apt upgrade` and `apt full-upgrade` now abort with `apt --fix-broken install` + `dpkg --configure -a` instructions instead of reporting "completed successfully" over a partially-upgraded system. - Made repository source writes atomic. Both writers tee into a `.tmp` file and move into place, and the `/etc/apt/sources.list` removal now happens after the write. - Corrected the SID warning text in migrate.sh to reflect that security fixes arrive via package uploads rather than a nonexistent sid-security suite. - Added exit-path cleanup traps for the temp `.deb` files: `trap 'rm -f "$deb_path"' RETURN` in `heroic.sh`and `tools.sh`. - Tightened Heroic download handling: the API fetch uses `curl -fsS --connect-timeout 10 --max-time 30`, the download uses `curl -fsSL --max-time 300`, and the `.deb` is validated with both `dpkg-deb --info` and `dpkg-deb --contents`; `sudo apt install` is guarded with `if !` before the temporary file is deleted. - Tightened the OpenRGB install path: the Codeberg API fetch uses `curl -fsS --connect-timeout 10 --max-time 30` and the download `curl -fsSL --max-time 300`, with the same dual `dpkg-deb` integrity check as the Heroic fallback. - Guarded the OpenRGB post-install side effects: the script now aborts after removing the failed `.deb` if `sudo apt install` returns non-zero, so `modprobe i2c-dev`, `/etc/modules`, the `i2c` group membership, `udevadm`, and the `setcap` step no longer run when the package is absent.
170 lines
5.9 KiB
Bash
170 lines
5.9 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
|
|
echo -e "${YELLOW}contrib repository not enabled. Steam installation may fail.${NC}"
|
|
return 1
|
|
fi
|
|
|
|
# No active sources at all → bootstrap a complete configuration
|
|
if ! has_active_deb_sources; then
|
|
backup_current_repos
|
|
if ! bootstrap_repositories "main contrib"; then
|
|
return 1
|
|
fi
|
|
else
|
|
if [ -f /etc/apt/sources.list ]; then
|
|
sudo cp /etc/apt/sources.list "/etc/apt/sources.list.backup.$(date +%Y%m%d_%H%M%S)"
|
|
# Anchor to the space-delimited "main" component so mirror URLs
|
|
# containing "main" (e.g. https://main.example.com) are untouched.
|
|
sudo sed -i -E '/^deb / { /\bcontrib\b/! s/ main([[:space:]]|$)/ main contrib\1/ }' /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
|
|
fi
|
|
|
|
# Verify the component was actually added before reporting success
|
|
local contrib_ok=false
|
|
[ -f /etc/apt/sources.list ] && grep -Eq '^[^#]*\bcontrib\b' /etc/apt/sources.list 2>/dev/null && contrib_ok=true
|
|
[ -d /etc/apt/sources.list.d ] && grep -qr 'Components:.*\bcontrib\b' /etc/apt/sources.list.d/*.sources 2>/dev/null && contrib_ok=true
|
|
[ -d /etc/apt/sources.list.d ] && grep -qrE '^[^#]*\bcontrib\b' /etc/apt/sources.list.d/*.list 2>/dev/null && contrib_ok=true
|
|
if ! $contrib_ok; then
|
|
echo -e "${RED}Failed to enable contrib repository. Check your APT sources.${NC}"
|
|
return 1
|
|
fi
|
|
|
|
_ensure_apt_updated
|
|
echo -e "${GREEN}contrib repository enabled.${NC}"
|
|
return 0
|
|
}
|
|
|
|
install_gaming() {
|
|
# Hardware state is detected on demand; GPU_TYPE is
|
|
# consulted below for the NVIDIA hints.
|
|
_ensure_state_detected
|
|
|
|
echo -e "${YELLOW}Gaming setup...${NC}"
|
|
|
|
# 1. Single checklist with ALL options (including i386 toggle)
|
|
local choices
|
|
choices=$(_checklist "Gaming Setup" \
|
|
"Check [*] the packages you want installed/updated on your system.\n" $TUI_ALTO $TUI_ANCHO $TUI_ALTO_LISTA \
|
|
"i386" "Enable 32-bit (i386) architecture" ON \
|
|
"steam" "Steam (requires 32-bit support)" ON \
|
|
"mangohud" "Performance overlay (Vulkan/OpenGL)" ON \
|
|
"gamemode" "Game performance optimization" OFF \
|
|
"goverlay" "MangoHud config GUI" ON \
|
|
"heroic" "Heroic Launcher (Epic/GOG)" OFF \
|
|
"java" "Minecraft Java Runtime" OFF \
|
|
"openrgb" "OpenRGB (RGB lighting control)" OFF \
|
|
"lutris" "Lutris + Wine (requires 32-bit support)" OFF \
|
|
"retroarch" "RetroArch Emulator Frontend" OFF)
|
|
|
|
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
|
|
|
|
local -a install_pkgs=()
|
|
while IFS= read -r _pkg; do
|
|
[ -n "$_pkg" ] && install_pkgs+=("$_pkg")
|
|
done < <(echo "$cleaned" | tr ' ' '\n')
|
|
|
|
for p in "${install_pkgs[@]}"; 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 -a install_list=()
|
|
while IFS= read -r _pkg; do
|
|
[ "$_pkg" = "i386" ] && continue
|
|
[ -n "$_pkg" ] && install_list+=("$_pkg")
|
|
done < <(echo "$cleaned" | tr ' ' '\n')
|
|
|
|
# 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
|
|
_ensure_apt_updated
|
|
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
|
|
}
|