# Can a state script access update information?

**URL:** <https://hub.mender.io/t/can-a-state-script-access-update-information/661>\
**Category:** General Discussions\
**Tags:** state-scripts\
**Created:** [June 3, 2019, 3:09pm UTC](https://hub.mender.io/t/can-a-state-script-access-update-information/661 "2019-06-03T15:09:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbensoussan](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/dbensoussan/32/263_2.png) [@dbensoussan](https://hub.mender.io/u/dbensoussan)\
**Post date:** [June 3, 2019, 3:09pm UTC](https://hub.mender.io/t/can-a-state-script-access-update-information/661/1 "2019-06-03T15:09:40Z")

</div>

Hi,  
We’re running a service which would need to access some data from the update, such as the future version.  
Is there a way to access this in a state script before rebooting? Environment variables during state scripts or reading a file (json or so) would be great as it’s easily readble.

In the worst case, I could get the version by opening /etc/mender/artifact\_info of the other partition

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [June 4, 2019, 6:00am UTC](https://hub.mender.io/t/can-a-state-script-access-update-information/661/2 "2019-06-04T06:00:02Z")

</div>

Not directly. However, if you’re using Yocto you can autogenerate a state script which contains the value of `MENDER_ARTIFACT_NAME` and store it somewhere for the bigger script to read. Something aka:

```auto
do_compile_append() {
    cat > ${WORKDIR}/00_ArtifactInstall_Enter <<EOF
#!/bin/sh
echo ${MENDER_ARTIFACT_NAME} > /tmp/new-artifact-name
EOF
    install -m 755 ${WORKDIR}/00_ArtifactInstall_Enter ${MENDER_STATE_SCRIPTS_DIR}
}

```

Btw, the `/etc/mender/artifact_info` is not guaranteed to work in 2.0.0 and beyond, because it stores this info in the database instead. If you use rootfs updates only, it will usually coincide, but not when using update modules.

---

<div class="post-metadata">

**Author:** ![dbensoussan](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/dbensoussan/32/263_2.png) [@dbensoussan](https://hub.mender.io/u/dbensoussan)\
**Post date:** [June 4, 2019, 9:05am UTC](https://hub.mender.io/t/can-a-state-script-access-update-information/661/3 "2019-06-04T09:05:24Z")

</div>

I’m not using the 2.0 yet but that’s good to know. Is this example available in the documentation? I think it would be great to access some metadata during the update
