Files
debianito-post-install/modules/firmware.sh
T
stornic56 eec16d0c83 Add files via upload
update
2026-05-23 22:50:36 -05:00

73 lines
2.9 KiB
Bash

#!/usr/bin/env bash
install_firmware() {
local fw_pkgs=""
local fw_bpo
fw_bpo=$(apt-cache madison firmware-linux-nonfree 2>/dev/null | \
grep "${DEBIAN_CODENAME}-backports" | awk '{print $3}' | head -1)
if [ -n "$fw_bpo" ]; then
local fw_stable
fw_stable=$(apt-cache policy firmware-linux-nonfree 2>/dev/null | awk 'NR==3 {print $2; exit}')
fw_pkgs=" - firmware-linux-nonfree ${fw_bpo} (backports) / ${fw_stable} (stable)\n"
else
local fw_ver
fw_ver=$(apt-cache policy firmware-linux-nonfree 2>/dev/null | awk 'NR==3 {print $2; exit}')
fw_pkgs=" - firmware-linux-nonfree ${fw_ver}\n"
fi
if ! _confirm "Base Firmware" "Install firmware?\n\n${fw_pkgs}"; then
echo "Skipping base firmware."
return
fi
echo -e "${YELLOW}Installing base firmware...${NC}"
local pkg="firmware-linux-nonfree"
if [ "$(is_backports_enabled)" == true ] && [ -n "$fw_bpo" ]; then
_run_cmd "Firmware" "sudo apt install -y -t ${DEBIAN_CODENAME}-backports $pkg" "Installing firmware from backports..."
else
_run_cmd "Firmware" "sudo apt install -y $pkg" "Installing firmware..."
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..."
_run_cmd "WiFi" "sudo apt install -y firmware-brcm80211" "Installing Broadcom firmware..."
else
# Offer to install broadcom-sta-dkms for older chips
if _confirm "Broadcom WiFi" "Install broadcom-sta-dkms?\n\nRequired for this Broadcom chipset.\nCompiles a kernel module (needs linux-headers)."; then
_run_cmd "Broadcom" "sudo apt install -y linux-headers-$(uname -r) broadcom-sta-dkms" "Installing Broadcom driver..."
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
}