Simple question: is it possible and/or legitimate for a running snap to trigger a manual refresh of itself?
In our case we have a snap that runs a background service written in python, which does some processing and also periodically checks in with an API on our end. In some cases, when we release a new version of the snap we’d like to have a way to tell a client device to “update itself” to this new version, potentially ahead of the scheduled refresh. We can send this signal by setting a flag in the API, but I was wondering what - if anything - the client device should do to carry out the actual refresh. E.g. would just executing a shell command
snap refresh <snap_name>
be a sensible thing to do? Or maybe hitting the
snapd API, e.g. https://github.com/snapcore/snapd/wiki/REST-API#post-v2snaps (
though not sure how exactly authentication would be handled there EDIT: looks like the root user, which is what the script is running under, can access the API without authentication).
Any tips or advice would be appreciated!
A similar idea came out some months ago (see Allow snaps to refresh themselves) but, AFAIK is not implemented yet.
I love the idea btw, it could be done via
snapctl and would provide a natural upgrade process for apps that already feature a self-update GUI.
Right, we already have a good pipeline between the snap and snapd, and the general capability sounds good. What we need to do is find a way to surface that without it feeling offensive to users, which are already quite sensitive to the auto-refreshing capabilities of snaps. One idea is to have an explicit whitelist that is controlled by the user, and hook that up with the warnings feature that is already in development, so that the snap can warn the user about the fact it’s trying to update itself, and once whitelisted it can then perform such updates in the future without manual interactions. It’s also nice because even if it’s rejected, the user got a hint that the snap is attempting to update itself, and so might carry on that update manually.
Thanks for the quick follow-up! Given some of the other lively discussions around refreshing, I understand the sensitivities around the topic. In our case we mostly run the devices ourselves so that sensitivity isn’t quite there.
If this could be implemented in future that would be great!
(also sorry for not noticing the existing post on this - somehow didn’t turn up in my search…)