mirror of
https://github.com/stornic56/debianito-post-install.git
synced 2026-07-16 05:49:49 +00:00
Add files via upload
This commit is contained in:
+102
@@ -0,0 +1,102 @@
|
||||
#!/usr/bin/env bash
|
||||
# Debianito
|
||||
set -euo pipefail
|
||||
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
# -------------------
|
||||
# Load modules
|
||||
# -----------------
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
MODULES_DIR="${SCRIPT_DIR}/modules"
|
||||
|
||||
source "${MODULES_DIR}/utils.sh"
|
||||
source "${MODULES_DIR}/sudo_config.sh"
|
||||
source "${MODULES_DIR}/repos.sh"
|
||||
if [ -f "${MODULES_DIR}/firmware.sh" ]; then
|
||||
source "${MODULES_DIR}/firmware.sh"
|
||||
fi
|
||||
if [ -f "${MODULES_DIR}/gpu.sh" ]; then
|
||||
source "${MODULES_DIR}/gpu.sh"
|
||||
fi
|
||||
if [ -f "${MODULES_DIR}/gaming.sh" ]; then
|
||||
source "${MODULES_DIR}/gaming.sh"
|
||||
fi
|
||||
if [ -f "${MODULES_DIR}/extras.sh" ]; then
|
||||
source "${MODULES_DIR}/extras.sh"
|
||||
fi
|
||||
|
||||
# --------------------------
|
||||
# Global state
|
||||
# --------------------------
|
||||
REPOS_CONFIGURED=false
|
||||
DEBIAN_VERSION=""
|
||||
DEBIAN_CODENAME=""
|
||||
|
||||
# ---------------------------------
|
||||
# menu
|
||||
# ---------------------------------
|
||||
|
||||
if ! echo "╔" | grep -q "t"; then
|
||||
BOX_DRAWING=false
|
||||
else
|
||||
BOX_DRAWING=true
|
||||
fi
|
||||
|
||||
main_menu() {
|
||||
PS3="Select an option (1-7): "
|
||||
options=(
|
||||
"User Privileges & Feedback"
|
||||
"Configure repositories"
|
||||
"Setup Wireless & Firmware"
|
||||
"Configure Graphics Stack and Tools"
|
||||
"Gaming Setup and Performance"
|
||||
"Install extra applications"
|
||||
"Exit"
|
||||
)
|
||||
|
||||
while true; do
|
||||
echo ""
|
||||
printf "${RED}╔═══════ DEBIANITO ═══════════╗\n" >&2
|
||||
printf "║ Debian Post-Install Setup\n${NC}"
|
||||
|
||||
echo -e "\033[1;97m║─────────── SYSTEM INFO ─────┤\n${NC}\033[0m"
|
||||
echo "Detected: Debian ${DEBIAN_VERSION} (${DEBIAN_CODENAME})"
|
||||
echo "CPU: $(get_cpu_summary)"
|
||||
echo "RAM: $(get_ram_summary)"
|
||||
echo "GPU: $(get_gpu_summary)"
|
||||
echo "WiFi: $(get_wifi_summary)"
|
||||
echo ""
|
||||
|
||||
select opt in "${options[@]}"; do
|
||||
case $REPLY in
|
||||
1) config_sudo ;;
|
||||
2) configure_repos ;;
|
||||
3) install_firmware ;;
|
||||
4) install_gpu_drivers ;;
|
||||
5) install_gaming ;;
|
||||
6) install_extras ;;
|
||||
7) echo "Exiting."; exit 0 ;;
|
||||
*) echo "Invalid choice. Please try again." ;;
|
||||
esac
|
||||
break
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
# ----------------
|
||||
# Pre-run checks
|
||||
# ----------------
|
||||
check_root
|
||||
check_sudo
|
||||
|
||||
detect_debian_version
|
||||
detect_cpu_ram
|
||||
detect_gpu
|
||||
detect_wifi_chipset
|
||||
|
||||
main_menu
|
||||
@@ -0,0 +1,124 @@
|
||||
#!/usr/bin/env bash
|
||||
# extras.sh
|
||||
|
||||
install_extras() {
|
||||
echo -e "${YELLOW}Extra software installation...${NC}"
|
||||
|
||||
local fetch_pkg
|
||||
if [ "$DEBIAN_CODENAME" = "bookworm" ]; then
|
||||
fetch_pkg="neofetch"
|
||||
else
|
||||
fetch_pkg="fastfetch"
|
||||
fi
|
||||
|
||||
local choices
|
||||
choices=$(whiptail --title "Extra Software" --checklist \
|
||||
"Select programs to install (space to toggle, enter to confirm):" \
|
||||
22 75 15 \
|
||||
"lshw" "List hardware details" ON \
|
||||
"inxi" "System information tool" ON \
|
||||
"hardinfo" "Graphical system profiler" OFF \
|
||||
"fetch" "System info (${fetch_pkg})" ON \
|
||||
"cpufetch" "CPU info fetcher" ON \
|
||||
"cpu-x" "CPU-X (GUI alternative to CPU-Z)" ON \
|
||||
"btop" "Resource monitor (fancy top)" ON \
|
||||
"htop" "Interactive process viewer" ON \
|
||||
"vlc" "VLC media player" ON \
|
||||
"mpv" "Lightweight media player" OFF \
|
||||
"chromium" "Chromium web browser" OFF \
|
||||
"ttf-mscorefonts-installer" "Microsoft TrueType fonts" ON \
|
||||
"fonts-ubuntu" "Ubuntu font family" OFF \
|
||||
"gparted" "GNOME partition editor" OFF \
|
||||
"flatpak" "Flatpak application sandbox" OFF \
|
||||
"firefox" "Firefox from Mozilla (replaces ESR)" OFF \
|
||||
3>&1 1>&2 2>&3)
|
||||
|
||||
if [ -z "$choices" ]; then
|
||||
echo "No extra programs selected."
|
||||
return
|
||||
fi
|
||||
|
||||
local cleaned
|
||||
cleaned=$(echo "$choices" | tr -d '"')
|
||||
|
||||
for pkg in $cleaned; do
|
||||
case $pkg in
|
||||
fetch)
|
||||
sudo apt install -y "$fetch_pkg"
|
||||
;;
|
||||
firefox)
|
||||
install_firefox_mozilla
|
||||
;;
|
||||
*)
|
||||
sudo apt install -y "$pkg"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo -e "${GREEN}Extra software installed.${NC}"
|
||||
}
|
||||
|
||||
# ---------------------------------------------
|
||||
# Firefox from Mozilla official APT repository
|
||||
# ---------------------------------------------
|
||||
install_firefox_mozilla() {
|
||||
echo -e "${YELLOW}Installing Firefox from Mozilla...${NC}"
|
||||
|
||||
sudo apt install -y wget gpg
|
||||
|
||||
sudo install -d -m 0755 /etc/apt/keyrings
|
||||
|
||||
if [ ! -f /etc/apt/keyrings/packages.mozilla.org.asc ]; then
|
||||
wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- | \
|
||||
sudo tee /etc/apt/keyrings/packages.mozilla.org.asc > /dev/null
|
||||
echo "Mozilla signing key imported."
|
||||
else
|
||||
echo "Mozilla key already present."
|
||||
fi
|
||||
|
||||
local fingerprint
|
||||
fingerprint=$(gpg -n -q --import --import-options import-show /etc/apt/keyrings/packages.mozilla.org.asc 2>/dev/null | \
|
||||
awk '/pub/ { getline; gsub(/^ +| +$/, ""); print }')
|
||||
if [ "$fingerprint" != "35BAA0B33E9EB396F59CA838C0BA5CE6DC6315A3" ]; then
|
||||
echo -e "${RED}Warning: Mozilla signing key fingerprint mismatch!${NC}"
|
||||
echo "Expected: 35BAA0B33E9EB396F59CA838C0BA5CE6DC6315A3"
|
||||
echo "Got: $fingerprint"
|
||||
echo "Aborting Firefox installation for security."
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
if [ "$DEBIAN_CODENAME" = "bookworm" ]; then
|
||||
echo "deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" | \
|
||||
sudo tee /etc/apt/sources.list.d/mozilla.list > /dev/null
|
||||
else
|
||||
sudo tee /etc/apt/sources.list.d/mozilla.sources > /dev/null <<EOF
|
||||
Types: deb
|
||||
URIs: https://packages.mozilla.org/apt
|
||||
Suites: mozilla
|
||||
Components: main
|
||||
Signed-By: /etc/apt/keyrings/packages.mozilla.org.asc
|
||||
EOF
|
||||
fi
|
||||
|
||||
sudo tee /etc/apt/preferences.d/mozilla > /dev/null <<EOF
|
||||
Package: *
|
||||
Pin: origin packages.mozilla.org
|
||||
Pin-Priority: 1000
|
||||
EOF
|
||||
|
||||
sudo apt update
|
||||
sudo apt install -y firefox
|
||||
|
||||
echo -e "${GREEN}Firefox from Mozilla installed.${NC}"
|
||||
|
||||
if dpkg -l firefox-esr &> /dev/null; then
|
||||
if whiptail --title "Remove Firefox ESR" \
|
||||
--yesno "Firefox ESR is still installed. Do you want to remove it?" 8 60; then
|
||||
sudo apt remove -y firefox-esr
|
||||
echo "Firefox ESR removed."
|
||||
else
|
||||
echo "Keeping Firefox ESR alongside."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
install_firmware() {
|
||||
echo -e "${YELLOW}Installing base firmware...${NC}"
|
||||
local pkg="firmware-linux-nonfree"
|
||||
if [ "$(is_backports_enabled)" == true ]; then
|
||||
if whiptail --title "Firmware Backports" \
|
||||
--yesno "Backports is enabled.\nInstall firmware-linux-nonfree from backports (newer version)?" 10 60; then
|
||||
sudo apt install -y -t "${DEBIAN_CODENAME}-backports" $pkg
|
||||
else
|
||||
sudo apt install -y $pkg
|
||||
fi
|
||||
else
|
||||
sudo apt install -y $pkg
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}Base firmware installed.${NC}"
|
||||
|
||||
handle_wifi_firmware
|
||||
}
|
||||
|
||||
# ---------------------------
|
||||
# Specific WiFi firmware
|
||||
# ---------------------------
|
||||
handle_wifi_firmware() {
|
||||
if [ -z "$WIFI_CHIPSET" ] || [ "$WIFI_CHIPSET" = "No WiFi adapter found" ]; then
|
||||
echo "No WiFi adapter to configure."
|
||||
return
|
||||
fi
|
||||
|
||||
echo "Detected WiFi: $WIFI_CHIPSET"
|
||||
|
||||
# Broadcom IDs often start with 14e4:
|
||||
local broadcom_id
|
||||
broadcom_id=$(lspci -nn | grep -i network | grep -oP '14e4:[0-9a-fA-F]+' | head -n1)
|
||||
if [ -n "$broadcom_id" ]; then
|
||||
echo -e "${YELLOW}Broadcom wireless device found (ID: $broadcom_id)${NC}"
|
||||
|
||||
# List of device IDs supported by brcmsmac/brcmfmac
|
||||
local supported_ids="4357 4358 4360 4727 43a0 43a1 43a2 43b1"
|
||||
local device_id
|
||||
device_id=$(echo "$broadcom_id" | cut -d: -f2)
|
||||
|
||||
if echo "$supported_ids" | grep -qw "$device_id"; then
|
||||
echo "Chipset supported by firmware-brcm80211. Installing..."
|
||||
sudo apt install -y firmware-brcm80211
|
||||
else
|
||||
# Offer to install broadcom-sta-dkms for older chips
|
||||
if whiptail --title "Broadcom WiFi" \
|
||||
--yesno "Your Broadcom chipset may require the proprietary driver (broadcom-sta-dkms).\nThis will also install linux-headers and compile a kernel module.\n\nInstall broadcom-sta-dkms?" 12 70; then
|
||||
sudo apt install -y linux-headers-$(uname -r) broadcom-sta-dkms
|
||||
echo "Broadcom proprietary driver installed. A reboot may be required."
|
||||
else
|
||||
echo "Skipping Broadcom driver installation."
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "No special WiFi firmware needed for this adapter."
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
# Install gaming tools (Steam, gamemode, mangohud, etc.)
|
||||
|
||||
install_gaming() {
|
||||
echo -e "${YELLOW}Gaming setup...${NC}"
|
||||
|
||||
local choices
|
||||
choices=$(whiptail --title "Gaming Setup" --checklist \
|
||||
"Select gaming packages to install:" 15 70 5 \
|
||||
"steam" "Steam (official .deb from Valve, requires 32-bit)" ON \
|
||||
"gamemode" "Optimise system for gaming" ON \
|
||||
"mangohud" "Vulkan/OpenGL performance overlay" ON \
|
||||
"goverlay" "GUI for configuring MangoHud" OFF \
|
||||
"lutris" "Game launcher/runner" OFF \
|
||||
3>&1 1>&2 2>&3)
|
||||
|
||||
if [ -z "$choices" ]; then
|
||||
echo "No gaming packages selected."
|
||||
return
|
||||
fi
|
||||
|
||||
local cleaned
|
||||
cleaned=$(echo "$choices" | tr -d '"')
|
||||
|
||||
if echo "$cleaned" | grep -qw "steam"; then
|
||||
echo "Enabling 32-bit architecture (i386)..."
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt update
|
||||
fi
|
||||
|
||||
if [ "$(is_backports_enabled)" == true ]; then
|
||||
echo "Backports enabled. Installing newer Mesa from backports..."
|
||||
sudo apt install -y -t "${DEBIAN_CODENAME}-backports" libgl1-mesa-dri mesa-vulkan-drivers
|
||||
if dpkg --print-foreign-architectures | grep -q i386; then
|
||||
sudo apt install -y -t "${DEBIAN_CODENAME}-backports" libgl1-mesa-dri:i386 mesa-vulkan-drivers:i386
|
||||
fi
|
||||
fi
|
||||
|
||||
for pkg in $cleaned; do
|
||||
case $pkg in
|
||||
steam)
|
||||
echo "Downloading official Steam .deb..."
|
||||
local steam_deb="/tmp/steam_latest.deb"
|
||||
wget -O "$steam_deb" "https://cdn.fastly.steamstatic.com/client/installer/steam.deb"
|
||||
sudo apt install -y "$steam_deb"
|
||||
;;
|
||||
*)
|
||||
sudo apt install -y "$pkg"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo -e "${GREEN}Gaming setup complete.${NC}"
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
#!/usr/bin/env bash
|
||||
# Detects and installs GPU firmwares for AMD, Intel, and NVIDIA
|
||||
|
||||
install_gpu_drivers() {
|
||||
case "$GPU_TYPE" in
|
||||
amd) install_amd ;;
|
||||
intel) install_intel ;;
|
||||
nvidia) install_nvidia ;;
|
||||
*)
|
||||
echo -e "${YELLOW}No supported GPU detected or unknown GPU type.${NC}"
|
||||
echo "You can install GPU drivers manually later."
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
echo ""
|
||||
echo "Installing nvtop (GPU monitor) and vainfo (VA-API check)..."
|
||||
sudo apt install -y nvtop vainfo
|
||||
echo ""
|
||||
vainfo
|
||||
echo -e "${GREEN}GPU setup complete.${NC}"
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# AMD GPU
|
||||
# ----------------------------------------------------------------------
|
||||
install_amd() {
|
||||
echo -e "${YELLOW}Installing AMD GPU drivers and firmware...${NC}"
|
||||
sudo apt install -y firmware-amd-graphics radeontop
|
||||
echo -e "${GREEN}AMD drivers installed.${NC}"
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Intel GPU
|
||||
# ----------------------------------------------------------------------
|
||||
install_intel() {
|
||||
echo -e "${YELLOW}Installing Intel GPU firmware and drivers...${NC}"
|
||||
|
||||
# Base firmware
|
||||
sudo apt install -y firmware-intel-graphics
|
||||
|
||||
# Determine VA-API driver based on generation
|
||||
local gen
|
||||
gen=$(get_intel_generation)
|
||||
echo "Detected Intel GPU generation: $gen"
|
||||
|
||||
if [ "$gen" = "gen7-" ]; then
|
||||
echo "Gen 7 or older: installing i965-va-driver-shaders"
|
||||
sudo apt install -y i965-va-driver-shaders
|
||||
else
|
||||
echo "Gen 8 or newer: installing intel-media-va-driver-non-free"
|
||||
sudo apt install -y intel-media-va-driver-non-free
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}Intel GPU drivers installed.${NC}"
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# NVIDIA GPU
|
||||
# ----------------------------------------------------------------------
|
||||
install_nvidia() {
|
||||
echo -e "${YELLOW}NVIDIA GPU detected.${NC}"
|
||||
|
||||
# --- WARNING CHECK: Backports vs NVIDIA ---
|
||||
if [ "$(is_backports_enabled)" == true ]; then
|
||||
echo -e "${YELLOW}============================================${NC}"
|
||||
echo -e "${YELLOW} IMPORTANT: Backports are currently enabled${NC}"
|
||||
echo -e "${YELLOW}============================================${NC}"
|
||||
echo ""
|
||||
echo "If you are using a backports kernel (e.g., 6.19+), the NVIDIA"
|
||||
echo "driver (especially the 550 series on Debian Trixie) may fail to"
|
||||
echo "compile via DKMS due to kernel incompatibilities."
|
||||
echo ""
|
||||
echo "We strongly recommend using the stable Debian kernel with the"
|
||||
echo "NVIDIA driver. The script will now install the recommended driver"
|
||||
echo "from the STABLE repositories only, NOT from backports."
|
||||
|
||||
if ! whiptail --title "NVIDIA + Backports Warning" \
|
||||
--yesno "You have backports enabled.\n\nThere is a known conflict between backports kernels (6.19+) and the NVIDIA driver.\n\nDo you want to continue using the stable NVIDIA driver?\n\n(Choose No to skip NVIDIA installation)" 15 70; then
|
||||
echo "Skipping NVIDIA driver installation."
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Install nvidia-detect
|
||||
echo "Installing nvidia-detect..."
|
||||
sudo apt install -y nvidia-detect
|
||||
|
||||
# Run nvidia-detect and parse the recommended package
|
||||
echo "Detecting recommended NVIDIA driver..."
|
||||
local recommended
|
||||
recommended=$(nvidia-detect 2>/dev/null | grep -oP 'nvidia[\w-]+(?= package)')
|
||||
|
||||
if [ -z "$recommended" ]; then
|
||||
echo -e "${RED}nvidia-detect could not determine a suitable driver.${NC}"
|
||||
echo "Your GPU may not be supported by current Debian packages."
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Recommended driver package: $recommended"
|
||||
|
||||
# --- CHECK FOR UNSUPPORTED LEGACY DRIVERS ---
|
||||
if [[ "$recommended" =~ tesla-470|legacy-390|legacy-340 ]]; then
|
||||
if [ "$DEBIAN_CODENAME" = "trixie" ]; then
|
||||
echo -e "${RED}============================================${NC}"
|
||||
echo -e "${RED} NVIDIA DRIVER NOT AVAILABLE${NC}"
|
||||
echo -e "${RED}============================================${NC}"
|
||||
echo ""
|
||||
echo "Your GPU requires the $recommended driver, which is not available"
|
||||
echo "in Debian 13 (Trixie)."
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " 1. Install Debian 12 (Bookworm) where $recommended is still available"
|
||||
echo " 2. Use Debian Sid (Unstable) which may still provide $recommended"
|
||||
echo " 3. Use the open-source Nouveau driver (limited performance)"
|
||||
echo ""
|
||||
echo "No driver will be installed."
|
||||
return 1
|
||||
else
|
||||
# On Debian 12, tesla-470 is available; 390/340 are not in any supported Debian release
|
||||
if [[ "$recommended" =~ legacy-390|legacy-340 ]]; then
|
||||
echo -e "${RED}Your GPU requires $recommended, which is not available.${NC}"
|
||||
echo "No driver will be installed."
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# If we reach here, the recommended driver is installable
|
||||
sudo apt install -y "$recommended" firmware-misc-nonfree nvidia-vaapi-driver
|
||||
|
||||
echo -e "${GREEN}NVIDIA drivers installed.${NC}"
|
||||
echo "A reboot is required to load the NVIDIA kernel module."
|
||||
echo "After reboot, run 'nvidia-smi' to verify the installation."
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
configure_repos() {
|
||||
echo -e "${YELLOW}Repository configuration...${NC}"
|
||||
|
||||
|
||||
local use_deb822
|
||||
if whiptail --title "Repository Format" --defaultno \
|
||||
--yesno "Use the modern .sources (deb822) format?\n(default is classic one-line style)" 10 60; then
|
||||
use_deb822=true
|
||||
else
|
||||
use_deb822=false
|
||||
fi
|
||||
|
||||
|
||||
local enable_backports
|
||||
if whiptail --title "Backports" \
|
||||
--yesno "Enable backports?\nBackports provide newer versions of some software (kernel, drivers, Mesa) for better hardware support.\nIt is recommended to enable it (default: Yes)." 12 70; then
|
||||
enable_backports=true
|
||||
else
|
||||
enable_backports=false
|
||||
fi
|
||||
|
||||
|
||||
if $use_deb822; then
|
||||
generate_deb822_sources "$DEBIAN_CODENAME" "$enable_backports"
|
||||
else
|
||||
generate_classic_sources "$DEBIAN_CODENAME" "$enable_backports"
|
||||
fi
|
||||
|
||||
|
||||
echo "Updating package lists..."
|
||||
if sudo apt update; then
|
||||
REPOS_CONFIGURED=true
|
||||
echo -e "${GREEN}Repositories configured and updated successfully.${NC}"
|
||||
|
||||
local upgradable
|
||||
upgradable=$(apt list --upgradable 2>/dev/null | grep -c /)
|
||||
if [ "$upgradable" -gt 0 ]; then
|
||||
if whiptail --title "Upgrade System" \
|
||||
--yesno "There are $upgradable packages that can be upgraded.\n\nDo you want to upgrade them now?" 10 60; then
|
||||
sudo apt upgrade -y
|
||||
echo -e "${GREEN}System upgraded.${NC}"
|
||||
else
|
||||
echo "Skipping upgrade."
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}apt update failed. Please check your network and repository configuration.${NC}"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Generate classic sources.list
|
||||
# ----------------------------------------------------------------------
|
||||
generate_classic_sources() {
|
||||
local codename="$1"
|
||||
local backports="$2"
|
||||
|
||||
|
||||
if [ -f /etc/apt/sources.list ]; then
|
||||
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
echo "Backup of sources.list saved as sources.list.bak"
|
||||
fi
|
||||
|
||||
|
||||
local content=""
|
||||
content="# Official repository\n"
|
||||
content+="deb https://deb.debian.org/debian ${codename} main contrib non-free non-free-firmware\n"
|
||||
content+="# deb-src https://deb.debian.org/debian ${codename} main contrib non-free non-free-firmware\n\n"
|
||||
|
||||
content+="# Updates\n"
|
||||
content+="deb https://deb.debian.org/debian ${codename}-updates main contrib non-free non-free-firmware\n"
|
||||
content+="# deb-src https://deb.debian.org/debian ${codename}-updates main contrib non-free non-free-firmware\n\n"
|
||||
|
||||
content+="# Security\n"
|
||||
content+="deb https://security.debian.org/debian-security ${codename}-security main contrib non-free non-free-firmware\n"
|
||||
content+="# deb-src https://security.debian.org/debian-security ${codename}-security main contrib non-free non-free-firmware\n\n"
|
||||
|
||||
if $backports; then
|
||||
content+="# Backports (active)\n"
|
||||
content+="deb https://deb.debian.org/debian ${codename}-backports main contrib non-free non-free-firmware\n"
|
||||
content+="# deb-src https://deb.debian.org/debian ${codename}-backports main contrib non-free non-free-firmware\n"
|
||||
else
|
||||
content+="# Backports (not enabled)\n"
|
||||
content+="# deb https://deb.debian.org/debian ${codename}-backports main contrib non-free non-free-firmware\n"
|
||||
fi
|
||||
|
||||
|
||||
echo -e "$content" | sudo tee /etc/apt/sources.list > /dev/null
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Generate deb822 .sources format
|
||||
# ----------------------------------------------------------------------
|
||||
generate_deb822_sources() {
|
||||
local codename="$1"
|
||||
local backports="$2"
|
||||
|
||||
|
||||
sudo mkdir -p /etc/apt/sources.list.d
|
||||
|
||||
|
||||
sudo rm -f /etc/apt/sources.list.d/debian.sources
|
||||
|
||||
|
||||
local content=""
|
||||
content="Types: deb\n"
|
||||
content+="URIs: https://deb.debian.org/debian\n"
|
||||
content+="Suites: ${codename} ${codename}-updates\n"
|
||||
content+="Components: main contrib non-free non-free-firmware\n\n"
|
||||
|
||||
content+="Types: deb\n"
|
||||
content+="URIs: https://security.debian.org/debian-security\n"
|
||||
content+="Suites: ${codename}-security\n"
|
||||
content+="Components: main contrib non-free non-free-firmware\n\n"
|
||||
|
||||
if $backports; then
|
||||
content+="Types: deb\n"
|
||||
content+="URIs: https://deb.debian.org/debian\n"
|
||||
content+="Suites: ${codename}-backports\n"
|
||||
content+="Components: main contrib non-free non-free-firmware\n"
|
||||
else
|
||||
|
||||
true
|
||||
fi
|
||||
|
||||
echo -e "$content" | sudo tee /etc/apt/sources.list.d/debian.sources > /dev/null
|
||||
|
||||
|
||||
if [ -f /etc/apt/sources.list ]; then
|
||||
sudo mv /etc/apt/sources.list /etc/apt/sources.list.disabled
|
||||
echo "Classic sources.list disabled (renamed to sources.list.disabled)"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
# Adds user to sudo group and optionally enables pwfeedback
|
||||
|
||||
config_sudo() {
|
||||
echo -e "${YELLOW}Configuring sudo...${NC}"
|
||||
|
||||
|
||||
if groups "$USER" | grep -qE '\bsudo\b'; then
|
||||
echo "User is already in the sudo group."
|
||||
else
|
||||
echo "Adding user '$USER' to sudo group..."
|
||||
if sudo usermod -aG sudo "$USER"; then
|
||||
echo -e "${GREEN}Done. Note: you need to log out and back in for group changes to take effect.${NC}"
|
||||
else
|
||||
echo -e "${RED}Failed to add user to sudo group.${NC}"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
local answer
|
||||
answer=$(whiptail --title "Sudo Password Feedback" \
|
||||
--yesno "Show asterisks when typing the sudo password?" 8 60 3>&1 1>&2 2>&3)
|
||||
local exitstatus=$?
|
||||
if [ $exitstatus -eq 0 ]; then
|
||||
echo 'Defaults pwfeedback' | sudo tee /etc/sudoers.d/pwfeedback > /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "${GREEN}Password feedback enabled.${NC}"
|
||||
else
|
||||
echo -e "${RED}Failed to create /etc/sudoers.d/pwfeedback.${NC}"
|
||||
fi
|
||||
else
|
||||
echo "Skipping password feedback setting."
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
#!/usr/bin/env bash
|
||||
# Common utility functions for the post-install script
|
||||
|
||||
# ------------------
|
||||
# Global variables
|
||||
# ------------------
|
||||
CPU_SUMMARY=""
|
||||
RAM_SUMMARY=""
|
||||
GPU_TYPE=""
|
||||
GPU_DESC=""
|
||||
INTEL_GPU_DEVICE_ID=""
|
||||
NVIDIA_GPU_DEVICE_ID=""
|
||||
WIFI_SUMMARY="Not detected"
|
||||
WIFI_CHIPSET=""
|
||||
|
||||
# --------------------------
|
||||
# Pre-flight checks
|
||||
# --------------------------
|
||||
check_root() {
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
echo -e "${RED}Do not run this script as root. Use a normal user with sudo.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_sudo() {
|
||||
if ! sudo -v; then
|
||||
echo -e "${RED}This script requires sudo privileges.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# --------------------------------
|
||||
# Debian version detection
|
||||
# --------------------------------
|
||||
detect_debian_version() {
|
||||
if ! command -v lsb_release &> /dev/null; then
|
||||
echo -e "${YELLOW}Installing lsb-release...${NC}"
|
||||
sudo apt update -qq && sudo apt install -y -qq lsb-release
|
||||
fi
|
||||
DEBIAN_CODENAME=$(lsb_release -cs)
|
||||
case "$DEBIAN_CODENAME" in
|
||||
bookworm) DEBIAN_VERSION="12" ;;
|
||||
trixie) DEBIAN_VERSION="13" ;;
|
||||
*)
|
||||
echo -e "${RED}Unsupported Debian version: $DEBIAN_CODENAME. Only 12 (bookworm) and 13 (trixie) are supported.${NC}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# ----------------------------------
|
||||
# CPU and RAM info (cosmetic)
|
||||
# ----------------------------------
|
||||
detect_cpu_ram() {
|
||||
CPU_SUMMARY=$(grep -m1 'model name' /proc/cpuinfo | sed 's/.*: //')
|
||||
RAM_KB=$(grep MemTotal /proc/meminfo | awk '{print $2}')
|
||||
RAM_GB=$((RAM_KB / 1024 / 1024))
|
||||
RAM_SUMMARY="${RAM_GB} GB"
|
||||
}
|
||||
|
||||
get_cpu_summary() {
|
||||
echo "$CPU_SUMMARY"
|
||||
}
|
||||
|
||||
get_ram_summary() {
|
||||
echo "$RAM_SUMMARY"
|
||||
}
|
||||
|
||||
# ----------------------------------
|
||||
# GPU detection
|
||||
# ----------------------------------
|
||||
detect_gpu() {
|
||||
local gpu_line
|
||||
gpu_line=$(lspci -nn | grep -E "VGA|3D" | head -n1) || true
|
||||
if [ -z "$gpu_line" ]; then
|
||||
GPU_TYPE="unknown"
|
||||
GPU_DESC="No GPU detected"
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
GPU_DESC=$(echo "$gpu_line" | sed -E 's/.*: //; s/ *\(rev.*//')
|
||||
|
||||
if echo "$gpu_line" | grep -qi "AMD"; then
|
||||
GPU_TYPE="amd"
|
||||
elif echo "$gpu_line" | grep -qi "Intel"; then
|
||||
GPU_TYPE="intel"
|
||||
INTEL_GPU_DEVICE_ID=$(echo "$gpu_line" | grep -oP '8086:\K[0-9a-fA-F]+' | head -n1)
|
||||
if [ -n "$INTEL_GPU_DEVICE_ID" ]; then
|
||||
INTEL_GPU_DEVICE_ID="0x${INTEL_GPU_DEVICE_ID,,}"
|
||||
fi
|
||||
elif echo "$gpu_line" | grep -qi "NVIDIA"; then
|
||||
GPU_TYPE="nvidia"
|
||||
NVIDIA_GPU_DEVICE_ID=$(echo "$gpu_line" | grep -oP '10de:\K[0-9a-fA-F]+' | head -n1)
|
||||
else
|
||||
GPU_TYPE="unknown"
|
||||
fi
|
||||
}
|
||||
|
||||
get_gpu_summary() {
|
||||
if [ -n "$GPU_DESC" ]; then
|
||||
echo "$GPU_DESC"
|
||||
else
|
||||
echo "Unknown/Rare"
|
||||
fi
|
||||
}
|
||||
|
||||
# -------------------------------------
|
||||
# WiFi chipset detection
|
||||
# -------------------------------------
|
||||
WIFI_SUMMARY="Not detected"
|
||||
WIFI_CHIPSET=""
|
||||
WIFI_DESC=""
|
||||
|
||||
detect_wifi_chipset() {
|
||||
local net_line
|
||||
net_line=$(lspci -nn | grep -i 'Network controller' | head -n1) || true
|
||||
if [ -z "$net_line" ]; then
|
||||
WIFI_SUMMARY="No WiFi adapter found"
|
||||
WIFI_CHIPSET=""
|
||||
WIFI_DESC=""
|
||||
return
|
||||
fi
|
||||
WIFI_CHIPSET="$net_line"
|
||||
WIFI_DESC=$(echo "$net_line" | sed -E 's/^.*\]: //; s/ \[[0-9a-fA-F]{4}:[0-9a-fA-F]{4}\]//; s/ \(rev [0-9a-fA-F]+\)//')
|
||||
WIFI_SUMMARY="$WIFI_DESC"
|
||||
}
|
||||
|
||||
get_wifi_summary() {
|
||||
echo "$WIFI_SUMMARY"
|
||||
}
|
||||
|
||||
# ---------------------------------------
|
||||
# Intel HD Graphics generation detection
|
||||
# ---------------------------------------
|
||||
# Returns "gen7-" if Device ID < 0x1600, else "gen8+"
|
||||
get_intel_generation() {
|
||||
if [ -z "$INTEL_GPU_DEVICE_ID" ]; then
|
||||
# fallback: assume gen8+
|
||||
echo "gen8+"
|
||||
return
|
||||
fi
|
||||
local dev_int
|
||||
dev_int=$(printf "%d" "$INTEL_GPU_DEVICE_ID")
|
||||
if [ "$dev_int" -lt 5632 ]; then # 0x1600 = 5632
|
||||
echo "gen7-"
|
||||
else
|
||||
echo "gen8+"
|
||||
fi
|
||||
}
|
||||
|
||||
# ---------------------------------------------
|
||||
# Check if backports repository is enabled
|
||||
# ---------------------------------------------
|
||||
is_backports_enabled() {
|
||||
if [ "$REPOS_CONFIGURED" != true ]; then
|
||||
echo false
|
||||
return
|
||||
fi
|
||||
|
||||
# Check both classic and deb822 sources
|
||||
if [ -f /etc/apt/sources.list ]; then
|
||||
if grep -Eq '^[^#]*[ \t]+bookworm-backports[ \t]+' /etc/apt/sources.list 2>/dev/null; then
|
||||
echo true
|
||||
return
|
||||
fi
|
||||
if grep -Eq '^[^#]*[ \t]+trixie-backports[ \t]+' /etc/apt/sources.list 2>/dev/null; then
|
||||
echo true
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -d /etc/apt/sources.list.d ]; then
|
||||
if grep -qr 'backports' /etc/apt/sources.list.d/*.sources 2>/dev/null; then
|
||||
echo true
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
echo false
|
||||
}
|
||||
Reference in New Issue
Block a user