unifi-pfsense icon indicating copy to clipboard operation
unifi-pfsense copied to clipboard

Use UniFi's API to grab latest version

Open shaneallgeier opened this issue 5 years ago • 4 comments

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?)

shaneallgeier avatar Jun 27 '19 02:06 shaneallgeier

Perhaps mention this over in the active pull request (https://github.com/gozoinks/unifi-pfsense/pull/141) for this feature?

myfirstnameispaul avatar Jul 01 '19 14:07 myfirstnameispaul

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.

DelphiGuy1 avatar Aug 16 '19 18:08 DelphiGuy1

Isn't this just the firmware? it currently serves version 5.11.50 while the latest is 5.12.22

mattiaskagstrom avatar Nov 07 '19 21:11 mattiaskagstrom

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}";

the-wondersmith avatar Aug 06 '22 14:08 the-wondersmith