Reboot Device on Failure of Debian Module Install

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!

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

1 Like

Thanks! I’ll try that