Manual Deployment and State

For the integration of Mender into my project I have decided to only support “manual” deployments where my application will determine when to install a Mender artifact from either a USB drive or shared network location. My plan is for the application to spawn a shell to run ‘mender install --reboot-exit-code’ and monitor the returned status code. I assume zero (0) indicates there were no installation issues, four (4) that the device must be reboot, and any other value that there was some error in the installation process. Is this correct?

Typically, after installing a root filesystem, the return code will be four (4) indicating a re-boot is necessary to boot into the new root filesystem. After a reboot I need some mechanism that I can use to tell that this is a reboot immedately after a previous install so that I can decide to either “mender commit” or “mender rollback” the installation. I observed that if I do neither a commit or rollback and reboot it Mender loads that last known “good” partition automatically. The same behavior occurs if u-boot is unable to load and boot a newly installed partition (e.g. it automatically rolls back to the last known “good” partition).

So, I’m looking for a reliable mechanism (other than my application trying to track this state externally in a persistent partition) to query Mender and find out the state of the installation (e.g. is it waiting for a commit/rollback command before the next reboot)? This information must be stored somewhere already in Mender and I was hoping I could query that state. I saw in the U-Boot firmware state (via fw_printenv) that ‘upgrade_available=1’ when a commit/rollback can be done and it uses ‘mender_boot_part’ and ‘mender_boot_part_hex’ to determine which partition to ‘mender commit’. Is it safe to interrogate these U-Boot firmware state variables to determine the installation “state” of Mender? Is there a better Mender command I can issue to get similar information?

Finally, during an installation which can take several minutes on my platform due to the size of the root filesystem, the shelled ‘mender install’ command doesn’t appear to get much feedback on the progress of the installation other than logging messages. The artifact state scripts are only called at specific predefined points and don’t really provide a more fine-grained “progress” of the install. Certainly, programmatically parsing the textual output/logging of the ‘mender install’ command is difficult. Are there any suggestions on how to monitor the progress when starting the installation from the command-line in manual mode? Perhaps an option (e.g -json) where the output from ‘mender install’ could be formatted in an is easier to digest/parse form for a programming language. I’ve seen similar approaches used with the Linux ‘findmnt’ command-line tool. Is anything like that offered for Mender when it’s being operated in manual mode?

Thanks . . .