Trigger reboot after artifact install

I have created an artifact for my device using the directory-artifact-gen script, which I have modified slightly to allow me to pass through the --script parameter to mender-artifact for my ArtifactInstall_Leave_01 script. This script just copies some files around, unzips a .deb, and replaces some executables for my application.

However, this install process requires an OS reboot after completion. I can’t include a reboot command in my script because this interrupts the mender process resulting in a reported deployment failure.

I notice there is a state named “ArtifactReboot”, but as far as I can tell my device doesn’t go to this, but more likely reaches “ArtifactCommit” then returns to idle. I assume this Reboot state is used only for RootFS updates.

How do I ensure my device reboots after an artifact install without interrupting the mender update process?

Hi @craige,

Thanks for reaching out! The straightforward way is to make a customized version of the directory Update Module, and add the following “state”:

    NeedsArtifactReboot)
        echo "Automatic"
        ;;

See also the example Update Module: mender-update-modules/reboot/module/reboot at d8c4683e6660af6c65069e10ee4b8ee50ec1af46 · mendersoftware/mender-update-modules · GitHub

This will reboot the device after successful installation of the artifact. Besides that you can keep the Update Module and the generator script as they are, just make sure to pick a new unique name, like directory-reboot for the Update Module script file on the device, and the generator script to use as the type.

Greetz,
Josef

Thank you Josef, I’ll try that.

I’ve renamed my ‘directory’ script to ‘directory-reboot’, added that state, and updated my ‘directory-artifact-gen -T’ to point to the ‘directory-reboot’ script. Fingers crossed!

I’ve just realised you mentioned I would need to update this on the client. I have to perform this update on hundreds of devices, so presumably the new ‘directory-reboot’ script would have to form part of the artifact itself?

Hi @craige,

Yes and no. You can use the approach explained at How to install a new Update Module to streamline the process.

Greetz,
Josef