Best/Safest way to determine whether an update has taken place after a reboot?

Hi,
After booting up, we are trying to determine whether this is the “first boot” after a Mender update and therefore we should commit the update. (note: we’re running things in standalone mode)

Is there a recommended way to achieve this?

We have found two ways, both of which seem to be working reliably:

  1. Checking the exit code of mender -commit
  2. Parsing the output of fw_printenv upgrade_available

Is there a good reason on why we should go with one over the other or is it a matter of personal preference?

Hi @platisd,

We have found two ways, both of which seem to be working reliably:

  1. Checking the exit code of mender -commit
  2. Parsing the output of fw_printenv upgrade_available
    Is there a good reason on why we should go with one over the other or is it a matter of personal preference?

I think both methods will work. mender -commit actually checks that same flag.

But do you do anything else with this “upgrade in progress” information? Because if it is only to determinate if to commit or not, you can just run mender -commit unconditionally on each boot. The Mender client will know if there is something to commit, if not it will not do anything beside change the return code as you have noticed.

Thanks (again) for the immediate response.
We have to update other parts of our system (i.e. a microcontroller) so we do need to know whether this is the “first boot”.

Well, since there’s no other difference, I guess running mender -commit and checking its return code is better since it is one line of code less. :slight_smile:

Less is always better :slight_smile: and np