Sttate script

I have created an artifact and can deploy it on a rw file system.

Now I would like to deploy it on an read-only file system, The idea is to use state scripts to temporarily remount the rootfs in read-write mode.

I use the Download_Enter_00 script to mount in rw. This works.

Going back to read-only mode could be done by the ArtifactCommit_Leave_xx and ArtifactFailure_Leave_xx scripts. But these are part of the artifact. It doesn’t feel right to move the responsibility of going back to read-only to the update artifact.

I have also tried the Idle_Enter_xx script, but this script is also called when for example no action was performed. So every few seconds the file system is put back into read only mode.

  1. Is there a way to have ‘global’ ArtifactXY_Enter/Leave scripts which are not part of the artifact? But which can be installed directly in /etc/mender/scripts?
  2. Is there a way to retrieve the previous state in a state script? In that way I could check in the Idle_Enter script if we’re transitioning from ArtifactXY_Leave.

Hi @dwjbosman,

  1. Is there a way to have ‘global’ ArtifactXY_Enter/Leave scripts which are not part of the artifact? But which can be installed directly in /etc/mender/scripts?

Unfortunately not. The closest you will get to this are the Idle/Download states.

  1. Is there a way to retrieve the previous state in a state script? In that way I could check in the Idle_Enter script if we’re transitioning from ArtifactXY_Leave.

Not something that is offered by the Mender client, but you could easily achieve by having state-scripts e.g write to a file which then you can read in Idle_Enter, and determinate action based on content of this file.

Ok,

I have currently solved the issue by writing a temporary file in one state script and checking it in the next.

1 Like