File xone-dl-firmware of Package xone-dongle-firmware
#!/bin/bash
# Initialize exit_code to 1 (fail by default)
exit_code=1
# Check for --no-fail in arguments
for arg in "$@"; do
if [ "$arg" == "--no-fail" ]; then
exit_code=0
break
fi
done
if [ "$(id -u)" -ne 0 ]; then
echo 'This script must be run as root!' >&2
exit $exit_code
fi
if ! [ -x "$(command -v wget)" ]; then
echo 'Error: wget is required!' >&2
exit $exit_code
fi
if ! [ -x "$(command -v cabextract)" ]; then
echo 'This script requires cabextract!' >&2
exit $exit_code
fi
# Check if --skip-disclaimer is passed, if not display the disclaimer
if ! [[ "$@" =~ "--skip-disclaimer" ]]; then
echo "The firmware for the wireless dongle is subject to Microsoft's Terms of Use:"
echo 'https://www.microsoft.com/en-us/legal/terms-of-use'
echo
echo 'Press enter to continue!'
read -r _
fi
driver_url='http://download.windowsupdate.com/c/msdownload/update/driver/drvs/2017/07/1cd6a87c-623f-4407-a52d-c31be49e925c_e19f60808bdcbfbd3c3df6be3e71ffc52e43261e.cab'
firmware_hash='48084d9fa53b9bb04358f3bb127b7495dc8f7bb0b3ca1437bd24ef2b6eabdf66'
firmware_path="/usr/lib/firmware/xow_dongle.bin"
# Check if firmware exists
if [[ ! -e "$firmware_path" ]]; then
echo "Downloading Xbox Wireless Controller Adapter firmware..."
wget -O driver.cab "$driver_url"
if [[ $? -ne 0 ]]; then
echo "Failed to download the firmware. Please check your internet connection."
exit $exit_code
fi
cabextract -F FW_ACC_00U.bin driver.cab
if [[ $? -ne 0 ]]; then
echo "Failed to extract the firmware. Please try again."
exit $exit_code
fi
echo "$firmware_hash" FW_ACC_00U.bin | sha256sum -c
mv FW_ACC_00U.bin $firmware_path
rm driver.cab
echo "Firmware downloaded and installed."
else
echo "Firmware already exists. Skipping download."
fi