# Sttate script

**URL:** <https://hub.mender.io/t/sttate-script/2901>\
**Category:** General Discussions\
**Created:** [November 30, 2020, 12:07am UTC](https://hub.mender.io/t/sttate-script/2901 "2020-11-30T00:07:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dwjbosman](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/dwjbosman/32/961_2.png) [@dwjbosman](https://hub.mender.io/u/dwjbosman)\
**Post date:** [November 30, 2020, 12:07am UTC](https://hub.mender.io/t/sttate-script/2901/1 "2020-11-30T00:07:56Z")

</div>

I have created an artifact and can deploy it on a rw file system.

Now I would like to deploy it on an read-only file system, The idea is to use state scripts to temporarily remount the rootfs in read-write mode.

I use the Download\_Enter\_00 script to mount in rw. This works.

Going back to read-only mode could be done by the ArtifactCommit\_Leave\_xx and ArtifactFailure\_Leave\_xx scripts. But these are part of the artifact. It doesn’t feel right to move the responsibility of going back to read-only to the update artifact.

I have also tried the Idle\_Enter\_xx script, but this script is also called when for example no action was performed. So every few seconds the file system is put back into read only mode.

1. Is there a way to have ‘global’ ArtifactXY\_Enter/Leave scripts which are not part of the artifact? But which can be installed directly in /etc/mender/scripts?
2. Is there a way to retrieve the previous state in a state script? In that way I could check in the Idle\_Enter script if we’re transitioning from ArtifactXY\_Leave.

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [November 30, 2020, 7:24am UTC](https://hub.mender.io/t/sttate-script/2901/2 "2020-11-30T07:24:40Z")

</div>

Hi @dwjbosman,

> 1. Is there a way to have ‘global’ ArtifactXY\_Enter/Leave scripts which are not part of the artifact? But which can be installed directly in /etc/mender/scripts?

Unfortunately not. The closest you will get to this are the Idle/Download states.

> 1. Is there a way to retrieve the previous state in a state script? In that way I could check in the Idle\_Enter script if we’re transitioning from ArtifactXY\_Leave.

Not something that is offered by the Mender client, but you could easily achieve by having state-scripts e.g write to a file which then you can read in Idle\_Enter, and determinate action based on content of this file.

---

<div class="post-metadata">

**Author:** ![dwjbosman](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/dwjbosman/32/961_2.png) [@dwjbosman](https://hub.mender.io/u/dwjbosman)\
**Post date:** [November 30, 2020, 11:16am UTC](https://hub.mender.io/t/sttate-script/2901/3 "2020-11-30T11:16:25Z")

</div>

Ok,

I have currently solved the issue by writing a temporary file in one state script and checking it in the next.
