# Restart device and update existing python file in RPi

**URL:** <https://hub.mender.io/t/restart-device-and-update-existing-python-file-in-rpi/1998>\
**Category:** General Discussions\
**Created:** [June 3, 2020, 7:31am UTC](https://hub.mender.io/t/restart-device-and-update-existing-python-file-in-rpi/1998 "2020-06-03T07:31:25Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![oleorhagen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/oleorhagen/32/297_2.png) [@oleorhagen](https://hub.mender.io/u/oleorhagen)\
**Post date:** [June 15, 2020, 9:12am UTC](https://hub.mender.io/t/restart-device-and-update-existing-python-file-in-rpi/1998/11 "2020-06-15T09:12:11Z")

</div>

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](https://docs.mender.io/2.3/artifacts/state-scripts#power-loss)  
[2]: [https://docs.mender.io/2.3/devices/update-modules#power-loss](https://docs.mender.io/2.3/devices/update-modules#power-loss)  
[3]: [Script](https://hub.mender.io/t/script/328)

---

_[View the full topic](https://hub.mender.io/t/restart-device-and-update-existing-python-file-in-rpi/1998)._
