mirror of
https://github.com/stornic56/debianito-post-install.git
synced 2026-10-31 13:08:06 +00:00
89233b0750
- `.github/workflows/ci.yml` added as a new workflow: job `lint-and-test` on `runs-on: ubuntu-latest` with `container: debian:trixie`, checking out via `actions/checkout@v4`, installing `bats` and `shellcheck`, running `shellcheck --severity=error debianito.sh modules/**/*.sh` (with `shopt -s globstar`) and `bats tests/`.
- `debianito.sh` CLI parser: `AUTO_YES=0`, `ALLOW_DESTRUCTIVE=0` declared after `MODULES_DIR` and before `_boot_mark`; `_usage()` prints `Usage: debianito.sh [OPTIONS]` with `--yes`, `--allow-destructive` and `--help`; the `while [ $# -gt 0 ]` / `case` loop consumes `--yes` and `--allow-destructive`, prints `Unknown option: $1 (run with --help for usage)` to stderr and `exit 2` for unknown flags, and `--help|-h` runs `_usage` then `exit 0`.
- `modules/utils.sh`: new global `_SELECTION_CONFIRMED=0` and `_confirm_install_list()` (utils.sh:756-785), which renders items capped at 15 with `... and N more`, computes `height` capped at 24, calls `_confirm "$title" "$list" "$height" 65`, arms `_SELECTION_CONFIRMED=${#items[@]}` on yes, and returns 1 for an empty list or on decline. `_install_pkg()` (utils.sh:789-804) decrements the countdown instead of prompting, and only prompts via `elif ! _confirm "Install: ${pkg}" "Install ${pkg}\nVersion: ${ver}?"; then return 0`.
- Bulk retrofit in `modules/extras/**/*.sh` (18 sites): `_confirm_install_list "Título" "${array[@]}" || return` placed right after the `whiptail` selection is parsed, the install loop left intact, and `_SELECTION_CONFIRMED=0` after the loop. Files: office/office.sh:101, system/software_centers.sh:29, system/system.sh:133, communication/communication.sh:68, design/design.sh:42, download/download.sh:48+55, terminals/terminals.sh:31, security/security.sh:30, players/players.sh:20, themes/fonts/fonts.sh:32, dev/dev.sh:44, programming/programming.sh:57, themes/desktop-themes/desktop-themes.sh:30, fetch/fetch.sh:41, themes/icons/icons.sh:47, themes/cursors/cursors.sh:28, internet/internet.sh:197, java.
- `modules/bullseye/extras.sh` (13 sites) plus `modules/bullseye/legacy.sh` (1 site, `install_gaming_bullseye`, guarded with `if [ ${#_install_pkgs[@]} -gt 0 ]` so a i386-only selection does not blank the summary) plus `modules/desktop_display.sh` (1 site, XFCE Custom — a no-loop `_run_cmd` batch with the reset immediately after it). Special cases: download.sh and bullseye/download each have two checklists merged into one combined summary; legacy.sh gaming skips the reset when the list is empty; XFCE Custom resets before `_xfce_polkit_rules` so the counter cannot leak.
- `modules/desktops/desktop_gnome.sh` (new): `gnome_menu()` runs a `_radiolist` with "1" "GNOME (Full Desktop)", "2" "GNOME Core (Minimal Install)", "3" "Back", then `_install_gnome_full()` and `_install_gnome_core()`. Each arms `_confirm_install_list "GNOME Full Desktop" gnome gdm3 || return` (core: `gnome-core gdm3`), keeps an already-configured display manager via `_existing_display_manager` by setting `target_dm="$keep_dm"`, writes the preseed `echo "${target_dm} shared/default-x-display-manager select ${target_dm}" | sudo debconf-set-selections`, installs `sudo apt install -y gnome gdm3` / `gnome-core gdm3`, enables `gdm3` only when `target_dm = "gdm3"`, resets `_SELECTION_CONFIRMED=0` and calls `_offer_pipewire_after_desktop`.
- `modules/desktops/desktop_kde.sh` (new): `kde_menu()` runs a `_radiolist` with "1" "KDE Plasma (Full Desktop)", "2" "KDE Plasma Desktop (Minimal)", "3" "Back"; `_install_kde_full()` and `_install_kde_minimal()` arm `_confirm_install_list "KDE Plasma Full" kde-standard sddm || return` (minimal: `kde-plasma-desktop sddm`), preseed `sddm shared/default-x-display-manager select sddm`, install `sudo apt install -y kde-standard sddm` / `kde-plasma-desktop sddm`, enable `sddm` only when it is the target DM, reset the counter and offer PipeWire.
- `modules/desktop_display.sh` `desktop_environment_menu()`: `env_items+=("3" "GNOME")`, `env_items+=("4" "KDE Plasma")`, `env_items+=("5" "Back")`; the case adds `3)` loading `gnome` via `_load_module gnome || continue` and calling `gnome_menu`, and `4)` loading `kde` via `_load_module kde || continue` and calling `kde_menu`; the dead TODO comment was removed.
- PipeWire retrofit in `modules/desktop_display.sh` (6 sites): `_install_lxde_full`, `_install_lxde_core`, `_install_xfce_full`, `_install_xfce_minimal`, `_install_xfce_wayland` and `_install_xfce_custom` each call `_offer_pipewire_after_desktop` after their install block.
- `_offer_pipewire_after_desktop()` and `_existing_display_manager()` added at the end of `modules/desktop_display.sh`: `_offer_pipewire_after_desktop` checks `pipewire-audio` (`pipewire` when `DEBIAN_VERSION = 11`), returns 0 via `is_installed`, otherwise `_confirm "PipeWire Audio" "No PipeWire audio server is installed.\n\nInstall the PipeWire audio stack (recommended)?"` calls `_install_pipewire_standard` and returns 0. `_existing_display_manager` reads `${DM_FILE:-/etc/X11/default-display-manager}`, reads the basename as the DM, and otherwise scans `gdm3 lightdm sddm greetd gdm` with `systemctl is-enabled`, printing nothing when none is found.
- `_ensure_apt_updated` added before the GNOME/KDE `apt install` transactions (4 sites, deduplicated per session); `gnome gdm3` and `kde-standard sddm` are installed alongside even when another display manager is kept as the default.
- Extraction to `modules/desktops/`: `desktop_lxde.sh` (38 lines) and `desktop_xfce.sh` (119 lines) created with the `lxde_menu` / `_install_lxde_full` / `_install_lxde_core` and `xfce_menu` / `_install_xfce_full` / `_install_xfce_minimal` / `_install_xfce_wayland` / `_install_xfce_custom` / `_xfce_polkit_rules` blocks moved verbatim; both carry `# License GPL v3` in their headers.
- `modules/desktop_display.sh` reduced from 542 to 394 lines (−154): lines 55-208 removed, the dispatch (desktop_display.sh:39-46) replaced with `_load_module xfce || continue` / `lxde_menu`, and the file left with `manage_desktop_display`, `desktop_environment_menu`, `display_manager_menu`, `lightdm_config_menu`, `configure_greetd`, `configure_gdm3`, `configure_sddm`, the two shared helpers.
- `modules/utils.sh` `_load_module` map: `xfce)` → `${MODULES_DIR}/desktops/desktop_xfce.sh`, `lxde)` → `${MODULES_DIR}/desktops/desktop_lxde.sh`, `gnome)` → `${MODULES_DIR}/desktops/desktop_gnome.sh`, `kde)` → `${MODULES_DIR}/desktops/desktop_kde.sh`; deps for `xfce`, `lxde`, `gnome` and `kde` are `(desktop_display audio)` and `desktop_display` is `(repos audio)`.
- `modules/desktops/desktop_xfce.sh` `_xfce_polkit_rules()` writes `/etc/polkit-1/rules.d/85-suspend.rules` and `89-backlight.rules` via `sudo tee`, adds the `backlight` group with `groupadd --system` fallback, adds the real login user from `/etc/passwd` to `backlight` and restarts `polkit.service`.
- ES→EN user-facing strings: 14 strings across 4 files — `desktop_display.sh` `lxdе_menu` ("LXDE (Full Desktop)", "LXDE Core (Minimal Install)"), `gpu/nvidia.sh` Kepler legacy-driver notice ("Kepler GPU detected (GKxxx)… Install the legacy driver for Kepler?"), `bullseye/legacy.sh` ("Install NVIDIA driver?", "Skipping NVIDIA driver.", "Installing NVIDIA driver ${gpu_gen}...") and `bullseye/extras.sh` ("firmware-linux-nonfree provides drivers for… Install?").
- ES→EN internal comments: ~35 comments across 9 files — section headers in `_install_nvidia_standard`, `gpu/_helpers.sh` (lines 5, 113), `gpu/nvidia.sh` (lines 8-12, 19-22, 68-70, 167-172, 196, 239-253, 262-263, 275, 291, 336-338, 376), `gpu.sh` (lines 15-17), `bullseye/repos.sh` (line 2), `firmware.sh` (line 235, "--- Load verification ---"), `utils.sh` (lines 129, 132, 153 — timezone Paso 1/2/4) and `utils.sh:546,548`.
- set -e abort fix: `debianito.sh:149` now reads `_system_preferences_menu || true`, consistent with the other dispatch chains (14 of the 15 chains already had the guard); a declined pre-apply summary now leaves the TUI alive instead of terminating the script.
- `docs/desktops_display.md`: 4 hunks — intro now lists GNOME/GNOME Core/KDE Plasma/KDE Plasma Desktop/XFCE/XFCE Wayland/XFCE Custom/LXDE, a new "Modular layout" paragraph describing `modules/desktops/` and lazy loading, Block 1 rewritten into four environments, five new bullets (pre-apply summary, existing-DM preservation, PipeWire offer, stale-lists guard) and a Desktop Environment Packages table.
- `docs/quickstart.md` line 284: Desktop Environment entry expanded to pick from XFCE (full / minimal / Wayland `labwc` on Trixie / custom checklist), LXDE (full / core), GNOME (full / core) or KDE Plasma (full / minimal).
- `_existing_display_manager` now takes the config path via `local dm_file="${DM_FILE:-/etc/X11/default-display-manager}"` so the offline test suite never reads the real system file.
- `tests/test_helper.bash`: added `_mock_systemctl()` for `is-enabled` (units in `MOCK_SYSTEMCTL_ENABLED` report `enabled`, everything else `disabled`), `MOCK_SYSTEMCTL_ENABLED=""`, `WHIPTAIL_CALLS`/`MOCK_WHIPTAIL_OUTPUT`/`MOCK_WHIPTAIL_RC`, `MOCK_DPKG_INSTALLED` and the `systemctl` entry in the mock list and in `mock_reset()`.
- `tests/desktops.bats` created with 16 tests: `_existing_display_manager` (file read, file-preferred over an enabled unit, enabled-unit fallback, candidate order, missing file, nothing configured), `_offer_pipewire_after_desktop` (5 tests: skip-installed, accept-installs, decline-returns-0, Bullseye package name, wrong package name on 11), `_load_module` (4 tests for xfce/lxde/gnome/kde) and an unknown-module case; 17→33 tests total.
- `.github/workflows/ci.yml` shellcheck severity raised from `--severity=error` to `--severity=warning`.
- `debianito.sh`: `RED`, `GREEN`, `YELLOW`, `CYAN` and `NC` plus `AUTO_YES`, `ALLOW_DESTRUCTIVE` and `DEBIAN_CODENAME` are now `export`ed as cross-file globals.
- `modules/utils.sh`: `HAS_NVIDIA`, `DESKTOP_ENV`, `AUDIO_SERVER`, `DEBIAN_VERSION` and the other cross-file globals are `export`ed.
- `modules/extras/system/software_centers.sh` gained a `#!/usr/bin/env bash` shebang.
- `shellcheck` triage (v0.11.0, baseline `--severity=warning` 25 findings → 0): removed two dead-code lines (`headless` in `extras/dev/dev.sh`, orphan `dev_id` in `firmware.sh`); `SC2206` in `extras/dev/essential.sh` fixed by expanding `$comp_pkgs` to `"${comp_pkgs[@]}"`; `SC2010`/`SC2046` (3 sites) replaced `ls … | grep` with `compgen -G "…"`; `SC2155` (2 sites, `gpu.sh` and `rescue.sh`) split command substitutions into separate lines; `SC2166` in `repos.sh` replaced `-o` with `{ … || … }`; `SC2221`/`SC2222` (2 sites, `sysinfo.sh` and `utils.sh`) collapsed the `wl*|wlp*|wlo*|wlan*` alternation to `wl*`; `SC1090` in `extras.sh` gained a justification comment on the disable directive.
- Final verification: `bash -n` on all 15 modified `.sh` files and `set -euo pipefail` at `debianito.sh:3` both intact; `bats tests/` reports 33 ok / 0 failed; invariants `offers 11`, `confirm_install_list 39` and `_SELECTION_CONFIRMED=0 40` hold.
288 lines
9.3 KiB
Bash
288 lines
9.3 KiB
Bash
#!/usr/bin/env bash
|
|
# Debianito — simple configurator script
|
|
set -euo pipefail
|
|
|
|
# Colour palette shared with every lazily-loaded module:
|
|
# exported so shellcheck sees them as cross-file globals
|
|
# (SC2034) instead of unused locals.
|
|
export RED='\033[0;31m'
|
|
export GREEN='\033[0;32m'
|
|
export YELLOW='\033[1;33m'
|
|
export CYAN='\033[0;36m'
|
|
export NC='\033[0m'
|
|
|
|
# TUI dimensions — fixed centered size for whiptail dialogs
|
|
TUI_ALTO=20
|
|
TUI_ANCHO=78
|
|
TUI_ALTO_LISTA=10
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
MODULES_DIR="${SCRIPT_DIR}/modules"
|
|
|
|
# ── CLI flags (unattended mode) ──
|
|
# --yes: auto-confirm every prompt. Menus still
|
|
# display; only _confirm-style prompts auto-accept.
|
|
# --allow-destructive: lift the safety gate on
|
|
# destructive operations (e.g. branch migration).
|
|
# CLI flags consumed by the TUI helpers in modules/utils.sh
|
|
# (_confirm auto-accepts) and by destructive-operation gates.
|
|
# Exported because they are cross-file globals (SC2034).
|
|
export AUTO_YES=0
|
|
export ALLOW_DESTRUCTIVE=0
|
|
|
|
_usage() {
|
|
cat <<'EOF'
|
|
Usage: debianito.sh [OPTIONS]
|
|
|
|
Debian post-installation configurator (Debian 11/12/13).
|
|
|
|
Options:
|
|
--yes Auto-confirm all prompts (unattended mode).
|
|
Menus still require interaction.
|
|
--allow-destructive Allow destructive operations (e.g. branch
|
|
migration) without an extra safety gate.
|
|
--help Show this help and exit.
|
|
|
|
Examples:
|
|
./debianito.sh --yes
|
|
./debianito.sh --yes --allow-destructive
|
|
EOF
|
|
}
|
|
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
--yes) AUTO_YES=1 ;;
|
|
--allow-destructive) ALLOW_DESTRUCTIVE=1 ;;
|
|
--help|-h) _usage; exit 0 ;;
|
|
*)
|
|
echo "Unknown option: $1 (run with --help for usage)" >&2
|
|
exit 2
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
# Boot profiling: DEBIANITO_PROFILE=1 stamps each boot
|
|
# step to stderr for before/after comparison.
|
|
_boot_mark() {
|
|
[ "${DEBIANITO_PROFILE:-0}" = "1" ] || return 0
|
|
printf '[%s] %s\n' "$(date +%s%N)" "$*" >&2
|
|
}
|
|
|
|
_boot_mark "boot: start (before module sources)"
|
|
|
|
# Eager core only: utils.sh holds every boot function
|
|
# and TUI helper; hw_detect.sh declares the global
|
|
# device arrays (PCI_NET_DEVS, ...) that lazily-loaded
|
|
# modules read under `set -u`. All other modules are
|
|
# sourced on demand via _load_module() in main_menu().
|
|
source "${MODULES_DIR}/utils.sh"
|
|
source "${MODULES_DIR}/hw_detect.sh"
|
|
|
|
# ── Bullseye-specific modules (loaded only on Debian 11) ──
|
|
# Eager-conditional: the menu dispatch branches on
|
|
# `type install_*_bullseye`, so these must be defined
|
|
# before main_menu() runs.
|
|
if [ -d "${MODULES_DIR}/bullseye" ]; then
|
|
[ -f "${MODULES_DIR}/bullseye/legacy.sh" ] && source "${MODULES_DIR}/bullseye/legacy.sh"
|
|
[ -f "${MODULES_DIR}/bullseye/repos.sh" ] && source "${MODULES_DIR}/bullseye/repos.sh"
|
|
[ -f "${MODULES_DIR}/bullseye/extras.sh" ] && source "${MODULES_DIR}/bullseye/extras.sh"
|
|
fi
|
|
|
|
_boot_mark "boot: core modules loaded"
|
|
|
|
# ── Interrupt safety: restore repository state on Ctrl+C / TERM ──
|
|
_on_interrupt() {
|
|
echo -e "${RED}[!] Interrupted. Restoring repository state if possible...${NC}"
|
|
if type restore_previous_repos &>/dev/null; then
|
|
restore_previous_repos 2>/dev/null || true
|
|
fi
|
|
|
|
# Clean up temporary files created during execution
|
|
rm -rf /tmp/debianito.* 2>/dev/null || true
|
|
|
|
echo -e "${YELLOW}[!] Temp files cleaned.${NC}"
|
|
|
|
exit 130
|
|
}
|
|
trap _on_interrupt INT TERM
|
|
|
|
DEBIAN_VERSION=""
|
|
export DEBIAN_CODENAME=""
|
|
|
|
main_menu() {
|
|
# Auto-adjust TUI dimensions for small terminals
|
|
if [ "${LINES:-24}" -lt $((TUI_ALTO + 6)) ] || [ "${COLUMNS:-80}" -lt $((TUI_ANCHO + 6)) ]; then
|
|
TUI_ALTO=$((${LINES:-24} - 4 > 8 ? ${LINES:-24} - 4 : 8))
|
|
TUI_ANCHO=$((${COLUMNS:-80} - 4 > 50 ? ${COLUMNS:-80} - 4 : 50))
|
|
TUI_ALTO_LISTA=$((TUI_ALTO - 10 > 4 ? TUI_ALTO - 10 : 4))
|
|
fi
|
|
|
|
while true; do
|
|
sudo -v >/dev/null 2>&1 || true
|
|
local STATE_REFRESHED=false
|
|
local choice
|
|
choice=$(_menu "DEBIANITO — Simple Configurator Script" "" \
|
|
$TUI_ALTO $TUI_ANCHO $TUI_ALTO_LISTA \
|
|
"1" "System Information" \
|
|
"2" "User Privileges & Feedback" \
|
|
"3" "System Preferences" \
|
|
"4" "Configure Repositories" \
|
|
"5" "Firmware, Wireless & Bluetooth" \
|
|
"6" "Graphics Drivers & Mesa Stack" \
|
|
"7" "Kernel" \
|
|
"8" "Gaming Setup" \
|
|
"9" "ZRAM" \
|
|
"10" "Swap Management" \
|
|
"11" "Install Programs and Software" \
|
|
"12" "Boot Rescue + GRUB" \
|
|
"13" "Desktop & Display" \
|
|
"14" "Exit")
|
|
|
|
clear
|
|
|
|
case "$choice" in
|
|
1)
|
|
_load_module sysinfo || continue
|
|
_show_sysinfo
|
|
;;
|
|
2)
|
|
_load_module sudo_config || continue
|
|
config_sudo || true
|
|
;;
|
|
3)
|
|
_load_module system_prefs || continue
|
|
_system_preferences_menu || true
|
|
STATE_REFRESHED=true
|
|
;;
|
|
4)
|
|
if [ "$DEBIAN_VERSION" = "11" ] && type configure_repos_bullseye &>/dev/null; then
|
|
configure_repos_bullseye || true
|
|
else
|
|
_load_module repos || continue
|
|
configure_repos || true
|
|
fi
|
|
STATE_REFRESHED=true
|
|
;;
|
|
5)
|
|
if [ "$DEBIAN_VERSION" = "11" ] && type install_firmware_bullseye &>/dev/null; then
|
|
# Bullseye flow calls _handle_wireless
|
|
# from firmware.sh: load the module
|
|
# (cascades repo_detect, bluetooth, repos).
|
|
_load_module firmware || continue
|
|
install_firmware_bullseye || true
|
|
else
|
|
_load_module firmware || continue
|
|
install_firmware || true
|
|
fi
|
|
STATE_REFRESHED=true
|
|
;;
|
|
6)
|
|
_load_module gpu || continue
|
|
local gpu_sub
|
|
gpu_sub=$(_menu "Graphics Drivers" "" 12 50 2 \
|
|
"1" "Radeon/Intel Mesa" \
|
|
"2" "NVIDIA Drivers")
|
|
[ -z "$gpu_sub" ] && continue
|
|
clear
|
|
case $gpu_sub in
|
|
1) _install_amd_intel_stack || true ;;
|
|
2) _install_nvidia_stack || true ;;
|
|
esac
|
|
STATE_REFRESHED=true
|
|
;;
|
|
7)
|
|
_load_module kernel || continue
|
|
show_kernel_menu || true
|
|
STATE_REFRESHED=true
|
|
;;
|
|
8)
|
|
if [ "$DEBIAN_VERSION" = "11" ] && type install_gaming_bullseye &>/dev/null; then
|
|
# Bullseye flow calls the gaming bundle
|
|
# (ensure_contrib_repo, install_steam,
|
|
# install_mangohud, ...) and java.sh:
|
|
# load the bundle (cascades repo_detect,
|
|
# java, repos).
|
|
_load_module gaming || continue
|
|
install_gaming_bullseye || true
|
|
else
|
|
_load_module gaming || continue
|
|
install_gaming || true
|
|
fi
|
|
STATE_REFRESHED=true
|
|
;;
|
|
9)
|
|
_load_module zram || continue
|
|
zram_menu || true
|
|
STATE_REFRESHED=true
|
|
;;
|
|
10)
|
|
_load_module swap || continue
|
|
manage_swap || true
|
|
STATE_REFRESHED=true
|
|
;;
|
|
11)
|
|
if [ "$DEBIAN_VERSION" = "11" ] && type install_extras_bullseye &>/dev/null; then
|
|
# Bullseye flow calls _install_dev_java
|
|
# from extras/java.sh: load it explicitly.
|
|
_load_module java || continue
|
|
install_extras_bullseye || true
|
|
else
|
|
_load_module extras || continue
|
|
install_extras || true
|
|
fi
|
|
STATE_REFRESHED=true
|
|
;;
|
|
12)
|
|
_load_module rescue || continue
|
|
rescue_boot || true
|
|
STATE_REFRESHED=true
|
|
;;
|
|
13)
|
|
_load_module desktop_display || continue
|
|
manage_desktop_display || true
|
|
STATE_REFRESHED=true
|
|
;;
|
|
14)
|
|
echo "Exiting."
|
|
exit 0
|
|
;;
|
|
esac
|
|
if $STATE_REFRESHED; then
|
|
refresh_system_state
|
|
fi
|
|
done
|
|
}
|
|
|
|
_boot_mark "boot: pre-flight checks"
|
|
check_root
|
|
check_sudo
|
|
if ! command -v whiptail >/dev/null 2>&1; then
|
|
echo -e "${YELLOW}[+] whiptail not found. Installing required TUI dependencies...${NC}"
|
|
if _ensure_apt_updated && sudo apt-get install -y whiptail; then
|
|
echo -e "${GREEN}[+] whiptail installed.${NC}"
|
|
else
|
|
echo -e "${RED}[-] Could not install whiptail (no network?).${NC}" >&2
|
|
echo -e "${RED} The TUI menu requires it; install manually and re-run.${NC}" >&2
|
|
fi
|
|
fi
|
|
|
|
# Hardware detection is deferred on demand via
|
|
# _ensure_state_detected(); only the OS version is
|
|
# eager because the menu dispatch branches on it.
|
|
_boot_mark "boot: os detection"
|
|
detect_debian_version
|
|
|
|
# ── Bullseye-specific init (archive phase) ──
|
|
if [ "$DEBIAN_VERSION" = "11" ] && type check_bullseye_archive_phase &>/dev/null; then
|
|
check_bullseye_archive_phase
|
|
fi
|
|
|
|
if ! command -v whiptail >/dev/null 2>&1; then
|
|
echo -e "${RED}[-] whiptail is required for the TUI menu. Aborting.${NC}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
_boot_mark "boot: entering main menu"
|
|
main_menu
|