Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add firmware upgrade notification to status page #7597

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

aparcar
Copy link
Member

@aparcar aparcar commented Jan 30, 2025

This is likely not cleanly implemented, I'm unfamiliar with the LuCI tricks and JavaScript in general.

The core idea is to show a notification whenever a new firmware is available.

image

Right now it's just a notification, this could be extended to include the luci-app-attendedsysupgrade functionality or a slimmed down version.

@jow- please have a look

  • This PR is not from my main or master branch 💩, but a separate branch ✅
  • Each commit has a valid ✒️ Signed-off-by: <[email protected]> row (via git commit --signoff)
  • Each commit and PR title has a valid 📝 <package name>: title first line subject for packages
  • Incremented 🆙 any PKG_VERSION in the Makefile
  • Tested on: (architecture, openwrt version, browser) ✅
  • ( Preferred ) Mention: @ the original code author for feedback
  • ( Preferred ) Screenshot or mp4 of changes:
  • ( Optional ) Closes: e.g. openwrt/luci#issue-number
  • Description: (describe the changes proposed in this PR)

This allows each include to perform an action a single time but don't
run it on each poll. The function receives all data loaded via the
`load` function.

Signed-off-by: Paul Spooren <[email protected]>
If the UCI luci core section contain the option `check_firmware_version`
then a load of the status page checks if the download server offers a
new firmware compatible with the currently running device.

Signed-off-by: Paul Spooren <[email protected]>
&& boardinfo.release.version > data.stable_version
&& data.upcoming_version > boardinfo.release.version
&& checkDeviceAvailable(boardinfo, data.upcoming_version)) {
showUpgradeModal("upcomming", boardinfo.release.version, data.upcoming_version)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upcoming (or just new?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe "release candidate"? since I think that's the only thing ever to populate the upcoming_release field in .versions.json...

oneshot: function(data) {
var boardinfo = data[0];
var check_upgrades = uci.get_first('luci', 'core', 'check_firmware_version') || false;
console.log(check_upgrades)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop

}
})
.catch(error => {
console.error('Failed to fetch profile information:', error);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider adding more context to the error. A user who doesn't know about this feature might be confused by this err string, even though it's a console message.

@systemcrash
Copy link
Contributor

Consider using ui.addNotification() with perhaps a 60 second timeout, instead of ui.showModal(). Having a modal that a user must interact with to reach the interface causes friction (e.g. when a user logs in and perhaps needs to take care of something else more pressing).

// ui.addNotification(a, message, timeout, severity)
ui.addNotification(null, E('p', _('A new firmware is available.')), 60000, 'info');

]);
},

oneshot: function(data) {
var boardinfo = data[0];
var check_upgrades = uci.get_first('luci', 'core', 'check_firmware_version') || false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure but I think that should be 'main' and not 'core', assuming the js versions work like the cli tool:

$ uci show luci.core
uci: Entry not found

$ uci show luci.main
luci.main=core
luci.main.lang='auto'
luci.main.mediaurlbase='/luci-static/openwrt2020'
luci.main.resourcebase='/luci-static/resources'
luci.main.ubuspath='/ubus/'

@hnyman
Copy link
Contributor

hnyman commented Jan 31, 2025

Is this forced to all users? Also for those who regularly build their own builds every few days...

I am wondering if this should either

  • be non-default, a small LuCI package that is included in the release branch buildbot images but would not get be default into private builds, or
  • be called via a menu item (so that it is not in the front page).

In many OEM firmwares that I have seen, the upgrade check/notice is in a system admin menu, not on the front page.

(And hopefully the data is not polled by every 5 seconds)

@systemcrash
Copy link
Contributor

(And hopefully the data is not polled by every 5 seconds)

At most once a week is optimistic, once a month preferred (cronjob trigger?). But that's probably why the function is a oneshot. I suppose it could have a counter, and disable itself after a few tries, only to be activated after the next upgrade / reboot.

@aparcar
Copy link
Member Author

aparcar commented Jan 31, 2025

It runs every time you open the status page and does nothing in the background, why should it anyway.

It's not enabled by default but could be if users want that. A modal could open once and ask the user if they want to automatically check for upgrades when opening the web interface.

Additionally we could add a button somewhere to manually switch.

@efahl
Copy link
Contributor

efahl commented Jan 31, 2025

Additionally we could add a button somewhere to manually switch.

Putting a "Don't show me again" button right on the modal dialog would probably be pretty easy, it could just do uci.set('luci', 'main', 'check_firmware_version', 0) like is done at https://github.com/openwrt/luci/blob/master/modules/luci-mod-system/htdocs/luci-static/resources/view/system/system.js#L270

@hnyman
Copy link
Contributor

hnyman commented Jan 31, 2025

Putting a "Don't show me again" button right on the modal dialog would probably be pretty easy,

I feel that any automatic call-to-home should be opt-in, not something to be opted out. By default, the OpenWrt routers are currently not contacting OpenWrt servers before the user selects some action like opkg/APK that triggers the contact.

That "no automatic call-home" was the OpenWrt stance a few years ago, when there was discussion about collecting usage stats, device counts etc.

@aparcar
Copy link
Member Author

aparcar commented Jan 31, 2025

This is out of the question, it'd always be an opt in feature.

I'll see how to implement that and update this PR accordingly

@efahl
Copy link
Contributor

efahl commented Jan 31, 2025

It's already opt-in. The value for luci.main.check_firmware_version is undefined, so it results in false. You have to make an effort to explicitly add it to /etc/config/luci to turn it on...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants