# Determine update type in state script

**URL:** <https://hub.mender.io/t/determine-update-type-in-state-script/6431>\
**Category:** General Discussions\
**Tags:** state-scripts, mender-client\
**Created:** [December 26, 2023, 8:00am UTC](https://hub.mender.io/t/determine-update-type-in-state-script/6431 "2023-12-26T08:00:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zivkapl](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/zivkapl/32/2061_2.png) [@zivkapl](https://hub.mender.io/u/zivkapl)\
**Post date:** [December 26, 2023, 8:00am UTC](https://hub.mender.io/t/determine-update-type-in-state-script/6431/1 "2023-12-26T08:00:32Z")

</div>

Hi,

I need to have the state scripts do 2 different things when its an app update vs rootfs update.

How can I get that info (meaning - which artifact type is it) from inside the state script?  
thanks

---

<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:** [December 26, 2023, 9:21pm UTC](https://hub.mender.io/t/determine-update-type-in-state-script/6431/2 "2023-12-26T21:21:31Z")

</div>

Hi @zivkapl,

As the state script needs to be shipped with the artifact anyways in most cases, the simplest solution is to have two variants and pack those accordingly.

Greetz,  
Josef

---

<div class="post-metadata">

**Author:** ![zivkapl](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/zivkapl/32/2061_2.png) [@zivkapl](https://hub.mender.io/u/zivkapl)\
**Post date:** [January 9, 2024, 4:00pm UTC](https://hub.mender.io/t/determine-update-type-in-state-script/6431/3 "2024-01-09T16:00:55Z")

</div>

Thank you @TheYoctoJester

However, not all state scripts are shipped with the artifacts - and this is extemely relvant for rootfs upgrade type.

The pre-steps for rootfs upgrade are very much different and might even comflict with the custom upgrade module.

How would you approach that matter?

Is there any difference between `Download_Leave` and `ArtifactInstall_Enter`?  
Do you suggest to use only `ArtifactInstall_Enter` states and later?

Thanks

---

<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:** [January 9, 2024, 4:17pm UTC](https://hub.mender.io/t/determine-update-type-in-state-script/6431/4 "2024-01-09T16:17:18Z")

</div>

Hi @zivkapl,

Based on that information, its basically impossible to give any meaningful advice. I obviously don’t know which kind of conflict you are seeing, or in which context.

So just a few hopefully helpful pointers:

- `Download_Leave` is definitely different form `ArtifactInstall_Enter`. Examples: in a situation where there installation is delayed by a control map, the latter will not run until it is actually started. Also, `Download_Leave` will not run on a local artifact installation.
- you can also provide a custom rootfs Update Module, if you have specific needs.
- we offer support and professional services

Greetz,  
Josef

---

<div class="post-metadata">

**Author:** ![zivkapl](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/zivkapl/32/2061_2.png) [@zivkapl](https://hub.mender.io/u/zivkapl)\
**Post date:** [January 11, 2024, 10:55am UTC](https://hub.mender.io/t/determine-update-type-in-state-script/6431/5 "2024-01-11T10:55:41Z")

</div>

Thanks @TheYoctoJester for your responses!

> Also, `Download_Leave` will not run on a local artifact installation.

I followed the simple simple single-file module tutorial, and installed it locally (`mender install <artifact>`), which did triggered the existing `Download_Leave` that were already on the machine (as part of the. rootfs upgrade I configured).

Is it a bug? Is it a configuration I missed?

---

<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:** [January 11, 2024, 2:42pm UTC](https://hub.mender.io/t/determine-update-type-in-state-script/6431/6 "2024-01-11T14:42:16Z")

</div>

No, this is the correct behaviour @zivkapl 🙂

See here: [State scripts | Mender documentation](https://docs.mender.io/artifact-creation/state-scripts) for more information
