Restart device and update existing python file in RPi

I’m not a 100% understanding your question, so I going to answer:
“I have deployed a bash script which reboots the device, and the deployments gets stuck at 70% for a while in the Mender server, and then fails, what is going on?”

  1. Scripts cannot necessarily be used to reboot the device successfully in any state [1][2]. This is because: How can Mender differentiate a reboot in a state-script from a power-loss, or other significant device failures? Thus, the only state-script state which permits this kind of functionality is RebootEnter. Here a script which calls reboot can be run, and the Mender-client will be happy to reboot into the newly installed root-filesystem. If this is a script update module [3], it actually seems that the description on Mender-hub is wrong. This module does not support rebooting the device. I will fix this up, after clarifying with the Module author.

Thus, I guess what I am trying to say, is that rebooting the device at any time is not supported as it is now.

Solutions I can think of at the top of my head are:

  • Write a custom update-module which runs the script in the ArtifactReboot state. This will allow the script to reboot the device successfully, unlike the current ‘official’ script update-module.
  • Use some other tool to reboot the device (ssh? maybe), and keep it out of the Mender update loop.

Which solution is best is a little hard to say, as it depends on your specific use-case.

References:
[1]: https://docs.mender.io/2.3/artifacts/state-scripts#power-loss
[2]: https://docs.mender.io/2.3/devices/update-modules#power-loss
[3]: Script

1 Like