# Best approach for updating firmware on device that already runs a custom server

**URL:** https://hub.mender.io/t/best-approach-for-updating-firmware-on-device-that-already-runs-a-custom-server/6616
**Category:** General Discussions
**Created:** [March 12, 2024, 9:49am UTC](https://hub.mender.io/t/best-approach-for-updating-firmware-on-device-that-already-runs-a-custom-server/6616 "2024-03-12T09:49:10Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![marcel1991](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@marcel1991](https://hub.mender.io/u/marcel1991)
#### Post date: [March 12, 2024, 9:49am UTC](https://hub.mender.io/t/best-approach-for-updating-firmware-on-device-that-already-runs-a-custom-server/6616/1 "2024-03-12T09:49:10Z")

</div>

I have a device that runs a custom server that shows a frotend to a user which can be used to do some changes to the device itself. I now also want to add a functionality in that frotend for the user to upload and install a new firmware version to update the device itself.

My first idea was to use my custom frontend/server to upload an artifact in some folder and then to use the mender commands to install this artifact on the device. However to properly then install and start the new firmware I would have to reboot the device and also do some checks to verify proper reboot/restart with the new firmware and potentially then also do a rollback. This all seems to be supported by mender looking at the state diagram, however, I then found this statement in the documentation:

> Calling the Mender client from the command line with the `install` command will only invoke the two first states, `Download` and `ArtifactInstall`. Additionally, `ArtifactFailure` may be executed if there is an error.
> 
> Calling the Mender client from the command line with the `commit` command will only invoke the two last states, `ArtifactCommit` and `Cleanup`. Additionally, `ArtifactRollback` and `ArtifactFailure` may be executed if there is an error.
> 
> The `ArtifactReboot`, `ArtifactVerifyReboot` and `ArtifactRollbackReboot` states are never invoked when calling the Mender client from the command line.

Here: [https://raw.githubusercontent.com/mendersoftware/mender/master/support/modules/directory](https://raw.githubusercontent.com/mendersoftware/mender/master/support/modules/directory)

I am now a little bit confused. It seems I cannot do a reboot with checks and potential rollback with the mender client commands.

How am I supposed to implement a proper logic/architecture like I want to have?

Am I maybe on the wrong track and instead should better use the D-BUS API to control the mender deamon to check for a new update under a specifiy folder instead of using the mender client commands?

---

<div class="post-metadata">

### Author: ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)
#### Post date: [March 12, 2024, 1:44pm UTC](https://hub.mender.io/t/best-approach-for-updating-firmware-on-device-that-already-runs-a-custom-server/6616/2 "2024-03-12T13:44:26Z")

</div>

Hi @marcel1991,

In standalone mode you need to conduct the checks and decision if a rollback is required manually, and then instruct the client accordingly by issuing `mender-update rollback` (for the 4.0 client).

Greets,  
Josef

---

<div class="post-metadata">

### Author: ![marcel1991](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@marcel1991](https://hub.mender.io/u/marcel1991)
#### Post date: [March 12, 2024, 5:55pm UTC](https://hub.mender.io/t/best-approach-for-updating-firmware-on-device-that-already-runs-a-custom-server/6616/3 "2024-03-12T17:55:28Z")

</div>

Hi @TheYoctoJester,

So if i do a

```auto
sudo mender install 
sudo reboot

```

Will after reboot the state script **ArtifactReboot\_Leave** still be reached automatically and I could do some checks there, potentially then doing a mender rollback?
