Using script update module to reboot device

Hi, I’d like to create a simple artifact to reboot devices using the “script” update module. I created a bash script that will reboot the device, but this reboot ends up causing the Mender client to transition to the ArtifactFailure state and report the artifact_name as INCONSISTENT. I assume there is something I am missing with reporting to Mender that the script was actually successful as it causes a reboot before it can give an exit code…

What is the proper way to approach rebooting using the script update module? Thanks!

Hi @edocklea I think the best approach here would be to generate essentially a null artifact that uses a post-commit state script to do the reboot. Any reboot that happens before the commit will result in the behavior you see. The actual update module and payload content can be essentially nothing.

Hope that helps.

Not exactly. It will result in an infinite reboot loop, because Mender will consider the script interrupted, and will retry it the next time it starts. However, if you make sure to save the fact that you rebooted somewhere, and return success the next time the Commit_Leave script is executed, then it should work.

Thanks for the responses! Just in case it helps someone else, I ended up creating a null artifact with an ArtifactCommit_Leave state script that handles checking reboot status as suggested. I check if a temp file exists and if so, remove it and exit successfully so the Mender client can complete the update. Otherwise, I create that temp file and do the reboot.