Conceptual use for remote update

If something already exists I apologize for not finding it and ask for sharing of url.

In the past (pre mender) we would manually manage our remote updates, initial stage being pushing of a tar file down to site. Included in the tar are update (version) specific scripts for any post handling of update.

I’ve no doubt there are several ways to accomplish this with mender. My challenge is in managing pushing tar file down and then running a script. One way is to develop specific update module that will untar the file and then execute a specific shell script for post processing - would this be the bets way to go? I am keen to hear thoughts.

Hi @colinbes,

Indeed this seems like a basic use case that it would be nice to have some better documentation / tutorials around.

As you mention there are many ways to achieve this. How is the software itself packaged (inside the tar file)? Is it simply an executable, or several executables? If several, should they end up in the same directory?

For the simplest case (single executable and need for scripting), you can do this:

  • Use the Single File Update Module. Your executable is the “Single File” that you will package.
  • Your script(s) should be packaged as State scripts. If it’s simply a post-install script, you can use the ArtifactInstall_Leave state, e.g. call your script ArtifactInstall_Leave_01_postinstall

To include your state script(s) with an Artifact using an Update Module, you can pass them to the Artifact generator in this way:

...
./single-file-artifact-gen -n ${ARTIFACT_NAME} -t ${DEVICE_TYPE} -d ${DEST_DIR} -o ${OUTPUT_PATH} ${FILE} -- -s ArtifactInstall_Leave_01_postinstall

Was this along the lines of what you were thinking?

Most helpful, thank you!

Can you point me to location where this is described as I’d like idea of passing in state script - but lots of questions (newbie).

  • Is ArtifactInstall_Leave_01_postinstall in your example an env variable that contains the script?
  • How does mender-client know to call this script in state state ArtifactInstall_Leave?

Sure, the most comprehensive overview of state scripts is in the documentation: https://docs.mender.io/2.2/artifacts/state-scripts

I see what the confusion is, this is perhaps not clearly enough explained, but the state scripts follow a naming convention on the file name to determine when they are executed: https://docs.mender.io/2.2/artifacts/state-scripts#transitions-and-ordering

So ArtifactInstall_Leave_01_postinstall is simply an executable script. The Mender knows where to call it because it parses the file name itself. :slight_smile:

Does that make sense?

I’d recommend to just try a dummy script (e.g. that touches a file) and include it using the Single File update module as mentioned above. Hopefully it will make sense once you test it out.

That make sense, thanks for your help.