# Reboot Device on Failure of Debian Module Install

**URL:** https://hub.mender.io/t/reboot-device-on-failure-of-debian-module-install/2809
**Category:** General Discussions
**Tags:** debian, update-modules, v3
**Created:** [November 10, 2020, 4:57pm UTC](https://hub.mender.io/t/reboot-device-on-failure-of-debian-module-install/2809 "2020-11-10T16:57:01Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![lizziemac](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/lizziemac/32/691_2.png) [@lizziemac](https://hub.mender.io/u/lizziemac)
#### Post date: [November 10, 2020, 4:57pm UTC](https://hub.mender.io/t/reboot-device-on-failure-of-debian-module-install/2809/1 "2020-11-10T16:57:01Z")

</div>

Hello all,  
I’m on mender-client version `2.2.0 runtime: go1.11.5` and would like to have the device that is running mender reboot on failure. My current state machine for `/usr/share/mender/modules/v3/deb` is the following:

```
#!/bin/sh
set -e

STATE="$1"
FILES="$2"

case "$STATE" in
    ArtifactInstall)
        yes | dpkg -i "$FILES"/files/*.deb
        ;;
    NeedsArtifactReboot)
        echo "Automatic"
        ;;
    SupportsRollback)
        echo "Yes"
        ;;
    ArtifactRollback)
        ;;
    ArtifactRollbackReboot)
        ;;
esac
exit 0

```

I’ve tried a few various setups in addition to this, including changing `Needs Reboot` from `Automatic` to `Yes`, having a reboot occur in ArtifactRollback (that didn’t go well), etc. Is there a way to guarantee that the device is rebooted always? On success and failure? I’ve observed that a lot of issues arise around dpkg locks, and rebooting is the most reliable way to resolve it.

I’m also OK with updating to a newer mender-client if need be.

Thanks!

---

<div class="post-metadata">

### Author: ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)
#### Post date: [November 10, 2020, 5:15pm UTC](https://hub.mender.io/t/reboot-device-on-failure-of-debian-module-install/2809/2 "2020-11-10T17:15:02Z")

</div>

Hi @lizziemac I _think_ what you want here is to use an ArtifactFailure state script rather than modifying the update module. Assuming the actual dpkg command fails the new package will _not_ have been installed and no rollback is necessary.

Drew

---

<div class="post-metadata">

### Author: ![lizziemac](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/lizziemac/32/691_2.png) [@lizziemac](https://hub.mender.io/u/lizziemac)
#### Post date: [November 10, 2020, 5:24pm UTC](https://hub.mender.io/t/reboot-device-on-failure-of-debian-module-install/2809/3 "2020-11-10T17:24:01Z")

</div>

Thanks! I’ll try that
