The Mender Client has the ability to run pre- and postinstall scripts, before and after it writes the root file system. However, Mender state scripts are more general and useful than pre/postinstall scripts because they run between any state transition, not just (before/after) the install state.
Common use cases are:
A State script can be run before (Enter) or after (Leave) each of the following states.
Most of the states also have an Error transition which runs if some error occurs while executing any script for the given state.
State scripts run as pre- and post-scripts to every state in the Mender state machine shown above. The state in which a given script runs is determined by the script name and index.
Exit codes from a state script can control the execution of the Mender state machine. Depending on the return code from the script the Mender client will:
The Mender client collects logs during an update. In case of a failure, these logs are sent to the Mender server. The output from state scripts are included in these logs. This is useful when troubleshooting intermittent update failures.
To learn more, have a look at the tutorial on how to implement State scripts.
Found errors? Think you can improve this documentation? Simply click the Edit link at the top of the page, and then the icon on Github to submit changes.
© 2020 Northern.tech AS