#!/bin/bash
# Ref: https://gist.github.com/johnjeffers/3006011ec7767a4101cdd118e8d64290
# status: working
WORKING_DIRECTORY=$HOME/Downloads/facetimehd_driver
if [ ! -d "$WORKING_DIRECTORY" ]; then
mkdir "$WORKING_DIRECTORY"
fi
cd $WORKING_DIRECTORY
if [ ! -d "facetimehd-firmware" ]; then
git clone https://github.com/patjak/facetimehd-firmware.git
cd facetimehd-firmware
else
cd facetimehd-firmware
git pull
fi
make && sudo make install
cd ..
# https://support.apple.com/kb/DL1837
if [ ! -f "bootcamp5.1.5769.zip" ]; then
aria2c https://download.info.apple.com/Mac_OS_X/031-30890-20150812-ea191174-4130-11e5-a125-930911ba098f/bootcamp5.1.5769.zip
fi
unzip bootcamp5.1.5769.zip
cd BootCamp/Drivers/Apple/
unrar x AppleCamera64.exe
dd bs=1 skip=1663920 count=33060 if=AppleCamera.sys of=9112_01XX.dat
dd bs=1 skip=1644880 count=19040 if=AppleCamera.sys of=1771_01XX.dat
dd bs=1 skip=1606800 count=19040 if=AppleCamera.sys of=1871_01XX.dat
dd bs=1 skip=1625840 count=19040 if=AppleCamera.sys of=1874_01XX.dat
sudo cp *.dat /usr/lib/firmware/facetimehd
cd ../../../
rm -fr "\$WinPEDriver\$" AutoUnattend.xml BootCamp
if [ ! -d "bcwc_pcie" ]; then
git clone https://github.com/patjak/bcwc_pcie.git
cd bcwc_pcie
else
cd bcwc_pcie
git pull
fi
make && sudo make install
sudo depmod
sudo modprobe -r facetimehd
sudo modprobe facetimehd
if ! grep -q "facetimehd" /etc/modules; then
echo facetimehd | sudo tee -a /etc/modules
fi