There has beeen a lot of interest in the ability to run pre- and postinstall scripts, before and after the Mender Client writes the root file system.

Mender 1.2 not only includes support for pre- and postinstall scripts, but more generally state scripts. State scripts are more general and useful than pre/postinstall scripts because they can be run between any state transition, not just (before/after) the install state. You can see the nine states supported by in the state script documentation.

Mender users will probably come up with a lot of interesting use cases for state scripts, and we will cover some of them below for inspiration.

Application data migration

In this case, application data like a user profile is stored in an SQLite database and a new column need to be added before starting the new version of the application. This can be achieved by adding a state script to ArtifactReboot_Enter (that would run after writing the new rootfs, but before rebooting). This script can then do the neccessary migrations on the data partition before the new version of the application is brought up after the reboot.

Update confirmation by end user

For many devices with a display that interacts with an end user, it is desirable to ask the user before applying the update. You have probably seen this on a smartphone, where it will ask you if you want to update to the latest release of Android or iOS and it only starts after you hit "Apply".

Mender state scripts enable this use case with a script written to create the dialog box on the UI framework used. The script will simply wait for user input, and Mender will wait with the update process while waiting for the script to finish. Depending on what the user selects, the script can return 0 (proceed) or 1 (stop). This script can be run in the Download_Enter state, for example.

Make sure to increase the default timeout for state scripts to enable this use case.

Custom sanity checks

Mender already automatically rolls back an update if it can not reach the Mender Server after the update is applied, in order to ensure another update can be deployed.

In addition, scripts in ArtifactCommit_Enter can do additional sanity checks to make sure that the device and applications are working as expected. For example, is the UI application running and responding .....read the rest of this announcement on Mender.io

Eystein Måløy Stenberg

Co-founder and responsible for products

eystein.maloy.stenberg@northern.tech

Next post Previous post

ECH2020
Northern.tech is supported by the European Commission under Horizon 2020 research and innovation programme. Read more