unifi-pfsense
unifi-pfsense copied to clipboard
Use UniFi's API to grab latest version
Hey guys, I recently discovered this API that the UniFi controller reaches out to check for updates. After some research & guessing, I ended up with this URL we can use to figure out the download link to the latest controller version:
https://fw-update.ubnt.com/api/firmware?filter=eq~~product~~unifi-controller&filter=eq~~platform~~unix&filter=eq~~channel~~release&sort=-version&limit=1
Unfortunately, I don't have the knowledge to actually implement this into the script. I leave it to one of the many capable members of this repo. (Perhaps @joshyrobot since he has a related PR?)
Perhaps mention this over in the active pull request (https://github.com/gozoinks/unifi-pfsense/pull/141) for this feature?
Think this should work. Just update install script
UNIFI_SOFTWARE_URL=$(curl -s 'https://fw-update.ubnt.com/api/firmware?filter=eq~~product~~unifi-controller&filter=eq~~platform~~unix&filter=eq~~channel~~release&sort=-version&limit=1' | jq '._embedded.firmware[0]._links.data.href' ) echo "Installing version - $UNIFI_SOFTWARE_URL";
Requirements are jq and curl.
Will post this over in request 141.
Isn't this just the firmware? it currently serves version 5.11.50 while the latest is 5.12.22
Adding an extra jq
operation will get just the version number.
I'll open a PR in a bit to update the "official" installation script to be able to pull either a "known good", specific, or latest version from the Ubiquiti servers.
UNIFI_SOFTWARE_URL=$(curl -s 'https://fw-update.ubnt.com/api/firmware?filter=eq~~product~~unifi-controller&filter=eq~~platform~~unix&filter=eq~~channel~~release&sort=-version&limit=1' | jq '._embedded.firmware[0]._links.data.href' | jq -r 'match("(([\\d]+[.]){2}[\\d]+)").string');
echo "Installing version - ${UNIFI_SOFTWARE_URL}";