#!/bin/bash
# Description: Update Raspberry Pi Firmware
# Destination: /usr/local/bin/update-fw
WHT="\033[0m"
FIN="\e[0m"

update_firmware(){
FWURL="https://github.com/pyavitz/firmware.git"
FWDEST="/lib/firmware/updates/brcm"
echo -e "${TXT}Checking firmware${FIN}" ...
if [ -e /etc/firmware ]; then
	:;
else
	sudo ln -sr /lib/firmware /etc/firmware;
fi
if [[ `command -v git` ]]; then
	:;
else
	sudo apt update
	sudo apt upgrade -y
	sudo apt install git -y;
fi
if [ -e ${FWDEST}/.git ]; then
	cd ${FWDEST}
	sudo git config pull.rebase false
	sudo git pull;
else
	sudo git clone ${FWURL} ${FWDEST};
fi
echo -e "${TXT}Done${FIN}".
cd ~
}

update_firmware