#!/bin/bash

# Linuxium's script to install Broadcom files

echo "$0: Extracting Broadcom files ..."
PURGE_UNZIP=false && [ ! $(sudo bash -c "command -v unzip") ] && sudo apt -y install unzip > /dev/null 2>&1 && PURGE_UNZIP=true
sudo rm -rf broadcom
sudo mkdir broadcom
cd broadcom
sudo wget https://chromium.googlesource.com/chromiumos/third_party/linux-firmware/+archive/upstream/master/brcm.tar.gz > /dev/null 2>&1
sudo mkdir brcm
cd brcm
sudo tar xvf ../brcm.tar.gz > /dev/null 2>&1
cd ..
sudo rm -f brcm.tar.gz
sed '1,/^exit$/d' < ../$0 | base64 -d | sudo tee $0.zip > /dev/null 2>&1
sudo unzip $0.zip > /dev/null 2>&1 > /dev/null 2>&1
sudo rm -f $0.zip
echo "$0: Installing Broadcom files ..."
sudo mkdir -p /lib/firmware/brcm
sudo cp -n brcmfmac43241b4-sdio.txt /lib/firmware/brcm
sudo cp -n brcmfmac43340-sdio.bin /lib/firmware/brcm
sudo cp -n brcmfmac43340-sdio.txt /lib/firmware/brcm
sudo cp -n BCM43341B0.hcd /lib/firmware/brcm
sudo cp -n brcmfmac4330-sdio.txt /lib/firmware/brcm
sudo cp -n brcmfmac43430-sdio.bin /lib/firmware/brcm
sudo cp -n brcmfmac43430-sdio.txt /lib/firmware/brcm
sudo cp -n brcm/* /lib/firmware/brcm
echo "$0: Reloading Broadcom driver ..."
sudo modprobe -r brcmfmac > /dev/null 2>&1
sudo modprobe brcmfmac > /dev/null 2>&1
if [ ! -d /lib/systemd/system ]; then
        echo "$0: Installation of Broadcom bluetooth service requires 'systemd' ... skipping service installation ..."
else
        echo "$0: Installing Broadcom bluetooth service ..."
	sudo cp brcmbt.service /lib/systemd/system
        sudo systemctl enable brcmbt.service
        echo "$0: Starting Broadcom bluetooth service ..."
        sudo systemctl start brcmbt.service
fi
cd ..
sudo rm -rf broadcom
[ ${PURGE_UNZIP} ] && sudo apt -y purge unzip > /dev/null 2>&1
echo "$0: Installation of Broadcom finished "
exit
[encoded data, 713097 characters]
AAgACADRAgAALQsIAAAA
