#!/bin/sh # Download and extract the wireless dongle firmware from Windows Update. # Port of install/firmware.sh from medusalix/xone. # # The firmware is subject to Microsoft's Terms of Use: # https://www.microsoft.com/en-us/legal/terms-of-use set -eu cd "$(dirname "$0")/.." firmware_url='http://download.windowsupdate.com/c/msdownload/update/driver/drvs/2017/07/1cd6a87c-623f-4407-a52d-c31be49e925c_e19f60808bdcbfbd3c3df6be3e71ffc52e43261e.cab' firmware_hash='48084d9fa53b9bb04358f3bb127b7495dc8f7bb0b3ca1437bd24ef2b6eabdf66' 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 _ command -v curl >/dev/null 2>&1 || { echo 'This script requires curl!' >&2; exit 1; } sha256() { if command -v sha256sum >/dev/null 2>&1; then sha256sum "$1" | cut -d' ' -f1 else shasum -a 256 "$1" | cut -d' ' -f1 fi } tmpdir=$(mktemp -d) trap 'rm -rf "$tmpdir"' EXIT INT HUP TERM fetch_firmware() { # fetch_firmware url=$1 hash=$2 outname=$3 echo "Downloading $outname..." curl -L --fail -o "$tmpdir/driver.cab" "$url" # Extract the firmware image (requires a libarchive-based tar, e.g. macOS). tar -xf "$tmpdir/driver.cab" -C "$tmpdir" actual=$(sha256 "$tmpdir/FW_ACC_00U.bin") if [ "$actual" != "$hash" ]; then echo "Firmware hash mismatch: $actual" >&2 exit 1 fi mkdir -p firmware mv "$tmpdir/FW_ACC_00U.bin" "firmware/$outname" echo "Firmware written to firmware/$outname" } fetch_firmware "$firmware_url" "$firmware_hash" xow_dongle.bin