Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- # breaking the code with SOLID
- function download_and_verify() {
- local url="$1"
- local filename="$2"
- wget -q "$url" -O "$filename"
- if [ -s "$filename" ]; then
- echo "Download de $filename bem-sucedido."
- else
- echo "Falha ao fazer o download de $filename."
- exit 1
- fi
- }
- function execute_with_sudo() {
- local command="$1"
- sudo $command
- }
- function update_system() {
- execute_with_sudo "apt update && apt upgrade"
- }
- function install_prerequisites() {
- execute_with_sudo "apt install linux-headers-$(uname -r) build-essential dkms"
- }
- function remove_old_drivers() {
- execute_with_sudo "apt purge bcmwl-kernel-source"
- }
- function install_broadcom_firmware() {
- local firmware_urls=("http://www.lwfinger.com/b43-firmware/broadcom-wl-5.100.138.tar.bz2"
- "http://downloads.openwrt.org/sources/broadcom-wl-5.10.56.27.3_mipsel.tar.bz2")
- local firmware_files=("broadcom-wl-5.100.138.tar.bz2"
- "broadcom-wl-5.10.56.27.3_mipsel.tar.bz2")
- for i in ${!firmware_urls[@]}; do
- download_and_verify "${firmware_urls[$i]}" "${firmware_files[$i]}"
- tar -xf "${firmware_files[$i]}"
- done
- if [ -e "${firmware_files[0]}" ] && [ -e "${firmware_files[1]}" ]; then
- execute_with_sudo "b43-fwcutter -w /lib/firmware broadcom-wl-5.100.138/linux/wl_apsta.o"
- else
- echo "Falha ao encontrar os arquivos de firmware necessários."
- exit 1
- fi
- }
- function load_b43_driver() {
- execute_with_sudo "modprobe b43"
- }
- function check_driver_status() {
- dmesg | grep b43
- }
- function main() {
- clear
- update_system
- install_prerequisites
- remove_old_drivers
- install_broadcom_firmware
- load_b43_driver
- check_driver_status
- }
- main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement