# State-script support in dir-overlay Update Module

**URL:** <https://hub.mender.io/t/state-script-support-in-dir-overlay-update-module/915>\
**Category:** General Discussions\
**Created:** [August 6, 2019, 4:30pm UTC](https://hub.mender.io/t/state-script-support-in-dir-overlay-update-module/915 "2019-08-06T16:30:30Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![speeltronics](https://avatars.discourse-cdn.com/v4/letter/s/6f9a4e/32.png) [@speeltronics](https://hub.mender.io/u/speeltronics)\
**Post date:** [August 6, 2019, 4:30pm UTC](https://hub.mender.io/t/state-script-support-in-dir-overlay-update-module/915/1 "2019-08-06T16:30:30Z")

</div>

> [@Directory Overlay](https://hub.mender.io/t/directory-overlay/529/1):
>
> dir-overlay-artifact-gen

Are you going to add support for module state scripts? I tried passing the -s and --script commands and it says unsupported option. Also curious about permissions. Will I need to run a state script to set the permissions on all the overlaid files? Might be handy to have the permissions and owners set from the current files permissions when the artifact is generated. The single-file generator already seems to handle the state scripts and permissions…

---

<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:** [August 7, 2019, 7:43am UTC](https://hub.mender.io/t/state-script-support-in-dir-overlay-update-module/915/2 "2019-08-07T07:43:19Z")

</div>

> Are you going to add support for module state scripts? I tried passing the -s and --script commands and it says unsupported option. Also curious about permissions. Will I need to run a state script to set the permissions on all the overlaid files? Might be handy to have the permissions and owners set from the current files permissions when the artifact is generated. The single-file generator already seems to handle the state scripts and permissions…

It would make sense to make these improvements similar to what is supported by the `single-file` generator.

Though I have no plans on making any updates as my priorities are else where. I created this as a reference and would happily take contributions to improve it.

---

<div class="post-metadata">

**Author:** ![speeltronics](https://avatars.discourse-cdn.com/v4/letter/s/6f9a4e/32.png) [@speeltronics](https://hub.mender.io/u/speeltronics)\
**Post date:** [August 8, 2019, 5:36pm UTC](https://hub.mender.io/t/state-script-support-in-dir-overlay-update-module/915/3 "2019-08-08T17:36:20Z")

</div>

I modified it to work like the single-file generator to allow passing in other arguments such as state scripts. Not sure how to contribute though, I can’t upload the file. Should I just post the code?

---

<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:** [August 8, 2019, 5:56pm UTC](https://hub.mender.io/t/state-script-support-in-dir-overlay-update-module/915/4 "2019-08-08T17:56:40Z")

</div>

A pull-request [here] ([mender-update-modules/dir-overlay/module-artifact-gen/dir-overlay-artifact-gen at master · mendersoftware/mender-update-modules · GitHub](https://github.com/mendersoftware/mender-update-modules/blob/master/dir-overlay/module-artifact-gen/dir-overlay-artifact-gen)) would be awesome.

There is some additional text on how to contribute here,

> [@About the Update Modules category](https://hub.mender.io/t/about-the-update-modules-category/314):
>
> This is the online resource for out-of-the-box and community-supported Update Modules. Update Modules are customizable, easy to write modules that define how the Mender client installs an update to a device. You can use an Update Module to install any type of software package, and they can be written in any language. You can read more about how Update Modules work in our [official documentation](https://docs.mender.io/client-installation/use-an-updatemodule). How to contribute If you have created an Update Module and you would like to share it with the comm…

---

<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:** [August 14, 2019, 2:13pm UTC](https://hub.mender.io/t/state-script-support-in-dir-overlay-update-module/915/5 "2019-08-14T14:13:09Z")

</div>

Support was added with this pull-request,

> <https://github.com/mendersoftware/mender-update-modules/pull/3>

Thanks @speeltronics

---

<div class="post-metadata">

**Author:** ![SamanRatna](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@SamanRatna](https://hub.mender.io/u/SamanRatna)\
**Post date:** [November 11, 2020, 2:32pm UTC](https://hub.mender.io/t/state-script-support-in-dir-overlay-update-module/915/7 "2020-11-11T14:32:09Z")

</div>

Hi guys,

I tried the directory overlay update exactly similar to [this](https://hub.mender.io/t/directory-overlay/529). But I get these situations. It seems something related to compatibility I guess. I am using Balena Fin with the Raspberry Pi 3 Computing module.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/1X/40c65193bb593220dfff08723373e34e3f9b813a.png)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/1X/c563de5e19d20d7a43d117a072e7b35b2d378bef.png)

Thanks in advance.

Saman

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [November 11, 2020, 2:46pm UTC](https://hub.mender.io/t/state-script-support-in-dir-overlay-update-module/915/8 "2020-11-11T14:46:22Z")

</div>

Your artifact is set to be compatible with ‘my-device-type’ but your actual device type is ‘raspberrypi3’. I think you missed a customization step in setting the variables for the artifact creation.

---

<div class="post-metadata">

**Author:** ![SamanRatna](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@SamanRatna](https://hub.mender.io/u/SamanRatna)\
**Post date:** [November 11, 2020, 4:06pm UTC](https://hub.mender.io/t/state-script-support-in-dir-overlay-update-module/915/9 "2020-11-11T16:06:34Z")

</div>

Thanks. I had forgotton to change my device\_type.

Now, I am getting this error after deployment. Here is the log.

```
2020-11-11 16:05:29 +0000 UTC info: Running Mender client version: 2.4.0
2020-11-11 16:05:36 +0000 UTC info: State transition: update-fetch [Download_Enter] -> update-store [Download_Enter]
2020-11-11 16:05:36 +0000 UTC info: No public key was provided for authenticating the artifact
2020-11-11 16:05:36 +0000 UTC info: Update module output: + STATE=Download
2020-11-11 16:05:36 +0000 UTC info: Update module output: + 
2020-11-11 16:05:36 +0000 UTC info: Update module output: FILES=/var/lib/mender/modules/v3/payloads/0000/tree
2020-11-11 16:05:36 +0000 UTC info: Update module output: + backup_dir=/var/lib/mender/modules/v3/payloads/0000/tree/tmp
2020-11-11 16:05:36 +0000 UTC info: Update module output: + dest_dir_file=/var/lib/mender/modules/v3/payloads/0000/tree/files/dest_dir
2020-11-11 16:05:36 +0000 UTC info: Update module output: + manifest_file_from_deployment=/var/lib/mender/modules/v3/payloads/0000/tree/files/manifest
2020-11-11 16:05:36 +0000 UTC info: Update module output: + update_files_tar=/var/lib/mender/modules/v3/payloads/0000/tree/files/update.tar
2020-11-11 16:05:36 +0000 UTC info: Update module output: + state_dir=/var/lib/mender/dir-overlay-install
2020-11-11 16:05:36 +0000 UTC info: Update module output: + manifest_file=/var/lib/mender/dir-overlay-install/manifest
2020-11-11 16:05:36 +0000 UTC info: Update module output: + manifest_file_prev=/var/lib/mender/dir-overlay-install/manifest.prev
2020-11-11 16:05:36 +0000 UTC info: Update module output: + prev_files_tar=/var/lib/mender/dir-overlay-install/backup.tar
2020-11-11 16:05:36 +0000 UTC info: Update module output: + exit 0
2020-11-11 16:05:36 +0000 UTC info: Update module output: + STATE=SupportsRollback
2020-11-11 16:05:36 +0000 UTC info: Update module output: + 
2020-11-11 16:05:36 +0000 UTC info: Update module output: FILES=/var/lib/mender/modules/v3/payloads/0000/tree
2020-11-11 16:05:36 +0000 UTC info: Update module output: + backup_dir=/var/lib/mender/modules/v3/payloads/0000/tree/tmp
2020-11-11 16:05:36 +0000 UTC info: Update module output: + dest_dir_file=/var/lib/mender/modules/v3/payloads/0000/tree/files/dest_dir
2020-11-11 16:05:36 +0000 UTC info: Update module output: + manifest_file_from_deployment=/var/lib/mender/modules/v3/payloads/0000/tree/files/manifest
2020-11-11 16:05:36 +0000 UTC info: Update module output: + update_files_tar=/var/lib/mender/modules/v3/payloads/0000/tree/files/update.tar
2020-11-11 16:05:36 +0000 UTC info: Update module output: + state_dir=/var/lib/mender/dir-overlay-install
2020-11-11 16:05:36 +0000 UTC info: Update module output: + manifest_file=/var/lib/mender/dir-overlay-install/manifest
2020-11-11 16:05:36 +0000 UTC info: Update module output: + manifest_file_prev=/var/lib/mender/dir-overlay-install/manifest.prev
2020-11-11 16:05:36 +0000 UTC info: Update module output: + prev_files_tar=/var/lib/mender/dir-overlay-install/backup.tar
2020-11-11 16:05:36 +0000 UTC info: Update module output: + echo Yes
2020-11-11 16:05:36 +0000 UTC info: Update module output: + exit 0
2020-11-11 16:05:37 +0000 UTC info: State transition: update-store [Download_Enter] -> update-after-store [Download_Leave]
2020-11-11 16:05:37 +0000 UTC info: State transition: update-after-store [Download_Leave] -> update-install [ArtifactInstall]
2020-11-11 16:05:37 +0000 UTC info: Update module output: + STATE=ArtifactInstall
2020-11-11 16:05:37 +0000 UTC info: Update module output: + 
2020-11-11 16:05:37 +0000 UTC info: Update module output: FILES=/var/lib/mender/modules/v3/payloads/0000/tree
2020-11-11 16:05:37 +0000 UTC info: Update module output: + backup_dir=/var/lib/mender/modules/v3/payloads/0000/tree/tmp
2020-11-11 16:05:37 +0000 UTC info: Update module output: + dest_dir_file=/var/lib/mender/modules/v3/payloads/0000/tree/files/dest_dir
2020-11-11 16:05:37 +0000 UTC info: Update module output: + manifest_file_from_deployment=/var/lib/mender/modules/v3/payloads/0000/tree/files/manifest
2020-11-11 16:05:37 +0000 UTC info: Update module output: + update_files_tar=/var/lib/mender/modules/v3/payloads/0000/tree/files/update.tar
2020-11-11 16:05:37 +0000 UTC info: Update module output: + state_dir=/var/lib/mender/dir-overlay-install
2020-11-11 16:05:37 +0000 UTC info: Update module output: + manifest_file=/var/lib/mender/dir-overlay-install/manifest
2020-11-11 16:05:37 +0000 UTC info: Update module output: + manifest_file_prev=/var/lib/mender/dir-overlay-install/manifest.prev
2020-11-11 16:05:37 +0000 UTC info: Update module output: + prev_files_tar=/var/lib/mender/dir-overlay-install/backup.tar
2020-11-11 16:05:37 +0000 UTC info: Update module output: + [-ne 0]
2020-11-11 16:05:37 +0000 UTC info: Update module output: /usr/share/mender/modules/v3/dir-overlay: 65: [: -ne: unexpected operator
2020-11-11 16:05:37 +0000 UTC info: Update module output: + cat /var/lib/mender/modules/v3/payloads/0000/tree/files/dest_dir
2020-11-11 16:05:37 +0000 UTC info: Update module output: + dest_dir=/home/pi/dir_overlay
2020-11-11 16:05:37 +0000 UTC info: Update module output: + mkdir -p /home/pi/dir_overlay /var/lib/mender/dir-overlay-install
2020-11-11 16:05:37 +0000 UTC info: Update module output: + [-e /var/lib/mender/dir-overlay-install/manifest]
2020-11-11 16:05:37 +0000 UTC info: Update module output: + mkdir -p /var/lib/mender/modules/v3/payloads/0000/tree/tmp
2020-11-11 16:05:37 +0000 UTC info: Update module output: + stat -c %a /home/pi/dir_overlay
2020-11-11 16:05:37 +0000 UTC info: Update module output: + chmod 755 /var/lib/mender/modules/v3/payloads/0000/tree/tmp
2020-11-11 16:05:37 +0000 UTC info: Update module output: + stat -c %U:%G /home/pi/dir_overlay
2020-11-11 16:05:37 +0000 UTC info: Update module output: + chown root:root /var/lib/mender/modules/v3/payloads/0000/tree/tmp
2020-11-11 16:05:37 +0000 UTC info: Update module output: + cat /var/lib/mender/dir-overlay-install/manifest
2020-11-11 16:05:37 +0000 UTC info: Update module output: + tar -cpf - /home/pi/dir_overlay/etc/app.conf
2020-11-11 16:05:37 +0000 UTC info: Update module output: + cd /var/lib/mender/modules/v3/payloads/0000/tree/tmp/
2020-11-11 16:05:37 +0000 UTC info: Update module output: + tar -xpf -
2020-11-11 16:05:37 +0000 UTC info: Update module output: tar: Removing leading `/' from member names
2020-11-11 16:05:37 +0000 UTC info: Update module output: tar: /home/pi/dir_overlay/etc/app.conf: Cannot stat: No such file or directory
2020-11-11 16:05:37 +0000 UTC info: Update module output: tar: Exiting with failure status due to previous errors
2020-11-11 16:05:37 +0000 UTC info: Update module output: + + cdtar -cpf /var/lib/mender/modules/v3/payloads/0000/tree/tmp/ -
2020-11-11 16:05:37 +0000 UTC info: Update module output: /home/pi/dir_overlay/usr/bin/app
2020-11-11 16:05:37 +0000 UTC info: Update module output: + tar -xpf -
2020-11-11 16:05:37 +0000 UTC info: Update module output: tar: Removing leading `/' from member names
2020-11-11 16:05:37 +0000 UTC info: Update module output: tar: /home/pi/dir_overlay/usr/bin/app: Cannot stat: No such file or directory
2020-11-11 16:05:37 +0000 UTC info: Update module output: tar: Exiting with failure status due to previous errors
2020-11-11 16:05:37 +0000 UTC info: Update module output: + tar -cpf - /home/pi/dir_overlay/usr/share/app/data.txt
2020-11-11 16:05:37 +0000 UTC info: Update module output: + cd /var/lib/mender/modules/v3/payloads/0000/tree/tmp/
2020-11-11 16:05:37 +0000 UTC info: Update module output: + tar -xpf -
2020-11-11 16:05:37 +0000 UTC info: Update module output: tar: Removing leading `/' from member names
2020-11-11 16:05:37 +0000 UTC info: Update module output: tar: /home/pi/dir_overlay/usr/share/app/data.txt: Cannot stat: No such file or directory
2020-11-11 16:05:37 +0000 UTC info: Update module output: tar: Exiting with failure status due to previous errors
2020-11-11 16:05:37 +0000 UTC info: Update module output: + tar -cpf /var/lib/mender/dir-overlay-install/backup.tar -C /var/lib/mender/modules/v3/payloads/0000/tree/tmp .
2020-11-11 16:05:37 +0000 UTC info: Update module output: + cat /var/lib/mender/dir-overlay-install/manifest
2020-11-11 16:05:37 +0000 UTC info: Update module output: + rm /home/pi/dir_overlay/etc/app.conf
2020-11-11 16:05:37 +0000 UTC info: Update module output: rm: cannot remove '/home/pi/dir_overlay/etc/app.conf': No such file or directory
2020-11-11 16:05:37 +0000 UTC error: Update module terminated abnormally: exit status 1
2020-11-11 16:05:37 +0000 UTC error: transient error: Update module terminated abnormally: exit status 1
2020-11-11 16:05:37 +0000 UTC info: State transition: update-install [ArtifactInstall] -> rollback [ArtifactRollback]
2020-11-11 16:05:37 +0000 UTC info: Performing rollback
2020-11-11 16:05:37 +0000 UTC info: Update module output: + STATE=ArtifactRollback
2020-11-11 16:05:37 +0000 UTC info: Update module output: + FILES=/var/lib/mender/modules/v3/payloads/0000/tree
2020-11-11 16:05:37 +0000 UTC info: Update module output: + backup_dir=/var/lib/mender/modules/v3/payloads/0000/tree/tmp
2020-11-11 16:05:37 +0000 UTC info: Update module output: + dest_dir_file=/var/lib/mender/modules/v3/payloads/0000/tree/files/dest_dir
2020-11-11 16:05:37 +0000 UTC info: Update module output: + manifest_file_from_deployment=/var/lib/mender/modules/v3/payloads/0000/tree/files/manifest
2020-11-11 16:05:37 +0000 UTC info: Update module output: + update_files_tar=/var/lib/mender/modules/v3/payloads/0000/tree/files/update.tar
2020-11-11 16:05:37 +0000 UTC info: Update module output: + state_dir=/var/lib/mender/dir-overlay-install
2020-11-11 16:05:37 +0000 UTC info: Update module output: + manifest_file=/var/lib/mender/dir-overlay-install/manifest
2020-11-11 16:05:37 +0000 UTC info: Update module output: + manifest_file_prev=/var/lib/mender/dir-overlay-install/manifest.prev
2020-11-11 16:05:37 +0000 UTC info: Update module output: + prev_files_tar=/var/lib/mender/dir-overlay-install/backup.tar
2020-11-11 16:05:37 +0000 UTC info: Update module output: + [-ne 0]
2020-11-11 16:05:37 +0000 UTC info: Update module output: /usr/share/mender/modules/v3/dir-overlay: 106: [: -ne: unexpected operator
2020-11-11 16:05:37 +0000 UTC info: Update module output: + cat /var/lib/mender/modules/v3/payloads/0000/tree/files/dest_dir
2020-11-11 16:05:37 +0000 UTC info: Update module output: + dest_dir=/home/pi/dir_overlay
2020-11-11 16:05:37 +0000 UTC info: Update module output: + test -f /var/lib/mender/dir-overlay-install/backup.tar
2020-11-11 16:05:37 +0000 UTC info: Update module output: + cp /var/lib/mender/dir-overlay-install/manifest.prev /var/lib/mender/dir-overlay-install/manifest
2020-11-11 16:05:37 +0000 UTC info: Update module output: cp: cannot stat '/var/lib/mender/dir-overlay-install/manifest.prev': No such file or directory
2020-11-11 16:05:37 +0000 UTC error: Update module terminated abnormally: exit status 1
2020-11-11 16:05:37 +0000 UTC error: Rollback failed: Update module terminated abnormally: exit status 1
2020-11-11 16:05:38 +0000 UTC error: fatal error: Update module terminated abnormally: exit status 1
2020-11-11 16:05:38 +0000 UTC info: State transition: rollback [ArtifactRollback] -> update-error [ArtifactFailure]
2020-11-11 16:05:38 +0000 UTC info: Update module output: + STATE=ArtifactFailure
2020-11-11 16:05:38 +0000 UTC info: Update module output: + FILES=/var/lib/mender/modules/v3/payloads/0000/tree
2020-11-11 16:05:38 +0000 UTC info: Update module output: + backup_dir=/var/lib/mender/modules/v3/payloads/0000/tree/tmp
2020-11-11 16:05:38 +0000 UTC info: Update module output: + dest_dir_file=/var/lib/mender/modules/v3/payloads/0000/tree/files/dest_dir
2020-11-11 16:05:38 +0000 UTC info: Update module output: + manifest_file_from_deployment=/var/lib/mender/modules/v3/payloads/0000/tree/files/manifest
2020-11-11 16:05:38 +0000 UTC info: Update module output: + update_files_tar=/var/lib/mender/modules/v3/payloads/0000/tree/files/update.tar
2020-11-11 16:05:38 +0000 UTC info: Update module output: + state_dir=/var/lib/mender/dir-overlay-install
2020-11-11 16:05:38 +0000 UTC info: Update module output: + manifest_file=/var/lib/mender/dir-overlay-install/manifest
2020-11-11 16:05:38 +0000 UTC info: Update module output: + manifest_file_prev=/var/lib/mender/dir-overlay-install/manifest.prev
2020-11-11 16:05:38 +0000 UTC info: Update module output: + prev_files_tar=/var/lib/mender/dir-overlay-install/backup.tar
2020-11-11 16:05:38 +0000 UTC info: Update module output: + exit 0
2020-11-11 16:05:38 +0000 UTC info: State transition: update-error [ArtifactFailure] -> cleanup [Error]
2020-11-11 16:05:38 +0000 UTC info: Update module output: + STATE=Cleanup
2020-11-11 16:05:38 +0000 UTC info: Update module output: + FILES=/var/lib/mender/modules/v3/payloads/0000/tree
2020-11-11 16:05:38 +0000 UTC info: Update module output: + backup_dir=/var/lib/mender/modules/v3/payloads/0000/tree/tmp
2020-11-11 16:05:38 +0000 UTC info: Update module output: + dest_dir_file=/var/lib/mender/modules/v3/payloads/0000/tree/files/dest_dir
2020-11-11 16:05:38 +0000 UTC info: Update module output: + manifest_file_from_deployment=/var/lib/mender/modules/v3/payloads/0000/tree/files/manifest
2020-11-11 16:05:38 +0000 UTC info: Update module output: + update_files_tar=/var/lib/mender/modules/v3/payloads/0000/tree/files/update.tar
2020-11-11 16:05:38 +0000 UTC info: Update module output: + state_dir=/var/lib/mender/dir-overlay-install
2020-11-11 16:05:38 +0000 UTC info: Update module output: + manifest_file=/var/lib/mender/dir-overlay-install/manifest
2020-11-11 16:05:38 +0000 UTC info: Update module output: + manifest_file_prev=/var/lib/mender/dir-overlay-install/manifest.prev
2020-11-11 16:05:38 +0000 UTC info: Update module output: + prev_files_tar=/var/lib/mender/dir-overlay-install/backup.tar
2020-11-11 16:05:38 +0000 UTC info: Update module output: + exit 0
2020-11-11 16:05:38 +0000 UTC info: State transition: cleanup [Error] -> update-status-report [none]

```

Thanks.

Saman

@drewmoseley - edited for formatting

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [November 11, 2020, 4:29pm UTC](https://hub.mender.io/t/state-script-support-in-dir-overlay-update-module/915/10 "2020-11-11T16:29:27Z")

</div>

It seems that for some reason you do not have a UID shell variable set but I thought that was a standard shell feature.

```
2020-11-11 16:05:37 +0000 UTC info: Update module output: /usr/share/mender/modules/v3/dir-overlay: 65: [: -ne: unexpected operator

```

What distro are you running? What is your default /bin/sh?

---

<div class="post-metadata">

**Author:** ![SamanRatna](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@SamanRatna](https://hub.mender.io/u/SamanRatna)\
**Post date:** [November 11, 2020, 4:56pm UTC](https://hub.mender.io/t/state-script-support-in-dir-overlay-update-module/915/11 "2020-11-11T16:56:47Z")

</div>

I am using Raspbian on my device.

/bin/sh ? Can you give some more info on that ? I am quite new on using linux.

Thanks.

Saman

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [November 11, 2020, 8:02pm UTC](https://hub.mender.io/t/state-script-support-in-dir-overlay-update-module/915/12 "2020-11-11T20:02:56Z")

</div>

It looks like there is a bug in the dir-overlay script.

If you can add:

`[-n "${UID}"] || UID=$(id -u)`

into the file `/usr/share/mender/modules/v3/dir-overlay` just before the line that reads:

`case "$STATE" in`

then you will probably get past this. I’ll submit that as a proper bugfix for future releases.

Drew

---

<div class="post-metadata">

**Author:** ![SamanRatna](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@SamanRatna](https://hub.mender.io/u/SamanRatna)\
**Post date:** [November 11, 2020, 8:15pm UTC](https://hub.mender.io/t/state-script-support-in-dir-overlay-update-module/915/13 "2020-11-11T20:15:32Z")

</div>

Hi @drewmoseley,

I am still getting the error.

```
2020-11-11 20:13:17 +0000 UTC info: Running Mender client version: 2.4.0
2020-11-11 20:13:19 +0000 UTC info: State transition: update-fetch [Download_Enter] -> update-store [Download_Enter]
2020-11-11 20:13:19 +0000 UTC info: No public key was provided for authenticating the artifact
2020-11-11 20:13:19 +0000 UTC info: Update module output: + STATE=Download
2020-11-11 20:13:19 +0000 UTC info: Update module output: + 
2020-11-11 20:13:19 +0000 UTC info: Update module output: FILES=/var/lib/mender/modules/v3/payloads/0000/tree
2020-11-11 20:13:19 +0000 UTC info: Update module output: + backup_dir=/var/lib/mender/modules/v3/payloads/0000/tree/tmp
2020-11-11 20:13:19 +0000 UTC info: Update module output: + dest_dir_file=/var/lib/mender/modules/v3/payloads/0000/tree/files/dest_dir
2020-11-11 20:13:19 +0000 UTC info: Update module output: + manifest_file_from_deployment=/var/lib/mender/modules/v3/payloads/0000/tree/files/manifest
2020-11-11 20:13:19 +0000 UTC info: Update module output: + update_files_tar=/var/lib/mender/modules/v3/payloads/0000/tree/files/update.tar
2020-11-11 20:13:19 +0000 UTC info: Update module output: + state_dir=/var/lib/mender/dir-overlay-install
2020-11-11 20:13:19 +0000 UTC info: Update module output: + manifest_file=/var/lib/mender/dir-overlay-install/manifest
2020-11-11 20:13:19 +0000 UTC info: Update module output: + manifest_file_prev=/var/lib/mender/dir-overlay-install/manifest.prev
2020-11-11 20:13:19 +0000 UTC info: Update module output: + prev_files_tar=/var/lib/mender/dir-overlay-install/backup.tar
2020-11-11 20:13:19 +0000 UTC info: Update module output: + [-n]
2020-11-11 20:13:19 +0000 UTC info: Update module output: + id -u
2020-11-11 20:13:19 +0000 UTC info: Update module output: + UID=0
2020-11-11 20:13:19 +0000 UTC info: Update module output: + exit 0
2020-11-11 20:13:19 +0000 UTC info: Update module output: + STATE=SupportsRollback
2020-11-11 20:13:19 +0000 UTC info: Update module output: + FILES=/var/lib/mender/modules/v3/payloads/0000/tree
2020-11-11 20:13:19 +0000 UTC info: Update module output: 
2020-11-11 20:13:19 +0000 UTC info: Update module output: + backup_dir=/var/lib/mender/modules/v3/payloads/0000/tree/tmp
2020-11-11 20:13:19 +0000 UTC info: Update module output: + dest_dir_file=/var/lib/mender/modules/v3/payloads/0000/tree/files/dest_dir
2020-11-11 20:13:19 +0000 UTC info: Update module output: + manifest_file_from_deployment=/var/lib/mender/modules/v3/payloads/0000/tree/files/manifest
2020-11-11 20:13:19 +0000 UTC info: Update module output: + update_files_tar=/var/lib/mender/modules/v3/payloads/0000/tree/files/update.tar
2020-11-11 20:13:19 +0000 UTC info: Update module output: + state_dir=/var/lib/mender/dir-overlay-install
2020-11-11 20:13:19 +0000 UTC info: Update module output: + manifest_file=/var/lib/mender/dir-overlay-install/manifest
2020-11-11 20:13:19 +0000 UTC info: Update module output: + manifest_file_prev=/var/lib/mender/dir-overlay-install/manifest.prev
2020-11-11 20:13:19 +0000 UTC info: Update module output: + prev_files_tar=/var/lib/mender/dir-overlay-install/backup.tar
2020-11-11 20:13:19 +0000 UTC info: Update module output: + [-n]
2020-11-11 20:13:19 +0000 UTC info: Update module output: + id -u
2020-11-11 20:13:19 +0000 UTC info: Update module output: + UID=0
2020-11-11 20:13:19 +0000 UTC info: Update module output: + echo Yes
2020-11-11 20:13:19 +0000 UTC info: Update module output: + exit 0
2020-11-11 20:13:20 +0000 UTC info: State transition: update-store [Download_Enter] -> update-after-store [Download_Leave]
2020-11-11 20:13:20 +0000 UTC info: State transition: update-after-store [Download_Leave] -> update-install [ArtifactInstall]
2020-11-11 20:13:20 +0000 UTC info: Update module output: + STATE=ArtifactInstall
2020-11-11 20:13:20 +0000 UTC info: Update module output: + 
2020-11-11 20:13:20 +0000 UTC info: Update module output: FILES=/var/lib/mender/modules/v3/payloads/0000/tree
2020-11-11 20:13:20 +0000 UTC info: Update module output: + backup_dir=/var/lib/mender/modules/v3/payloads/0000/tree/tmp
2020-11-11 20:13:20 +0000 UTC info: Update module output: + dest_dir_file=/var/lib/mender/modules/v3/payloads/0000/tree/files/dest_dir
2020-11-11 20:13:20 +0000 UTC info: Update module output: + manifest_file_from_deployment=/var/lib/mender/modules/v3/payloads/0000/tree/files/manifest
2020-11-11 20:13:20 +0000 UTC info: Update module output: + update_files_tar=/var/lib/mender/modules/v3/payloads/0000/tree/files/update.tar
2020-11-11 20:13:20 +0000 UTC info: Update module output: + state_dir=/var/lib/mender/dir-overlay-install
2020-11-11 20:13:20 +0000 UTC info: Update module output: + manifest_file=/var/lib/mender/dir-overlay-install/manifest
2020-11-11 20:13:20 +0000 UTC info: Update module output: + manifest_file_prev=/var/lib/mender/dir-overlay-install/manifest.prev
2020-11-11 20:13:20 +0000 UTC info: Update module output: + prev_files_tar=/var/lib/mender/dir-overlay-install/backup.tar
2020-11-11 20:13:20 +0000 UTC info: Update module output: + [-n]
2020-11-11 20:13:20 +0000 UTC info: Update module output: + id -u
2020-11-11 20:13:20 +0000 UTC info: Update module output: + UID=0
2020-11-11 20:13:20 +0000 UTC info: Update module output: + [0 -ne 0]
2020-11-11 20:13:20 +0000 UTC info: Update module output: + cat /var/lib/mender/modules/v3/payloads/0000/tree/files/dest_dir
2020-11-11 20:13:20 +0000 UTC info: Update module output: + dest_dir=/home/pi/dir_overlay
2020-11-11 20:13:20 +0000 UTC info: Update module output: + mkdir -p /home/pi/dir_overlay /var/lib/mender/dir-overlay-install
2020-11-11 20:13:20 +0000 UTC info: Update module output: + [-e /var/lib/mender/dir-overlay-install/manifest]
2020-11-11 20:13:20 +0000 UTC info: Update module output: + mkdir -p /var/lib/mender/modules/v3/payloads/0000/tree/tmp
2020-11-11 20:13:20 +0000 UTC info: Update module output: + stat -c %a /home/pi/dir_overlay
2020-11-11 20:13:20 +0000 UTC info: Update module output: + chmod 755 /var/lib/mender/modules/v3/payloads/0000/tree/tmp
2020-11-11 20:13:20 +0000 UTC info: Update module output: + stat -c %U:%G /home/pi/dir_overlay
2020-11-11 20:13:20 +0000 UTC info: Update module output: + chown root:root /var/lib/mender/modules/v3/payloads/0000/tree/tmp
2020-11-11 20:13:20 +0000 UTC info: Update module output: + cat /var/lib/mender/dir-overlay-install/manifest
2020-11-11 20:13:20 +0000 UTC info: Update module output: + + cdtar -cpf /var/lib/mender/modules/v3/payloads/0000/tree/tmp/
2020-11-11 20:13:20 +0000 UTC info: Update module output: - /home/pi/dir_overlay/etc/app.conf
2020-11-11 20:13:20 +0000 UTC info: Update module output: + tar -xpf -
2020-11-11 20:13:20 +0000 UTC info: Update module output: tar: Removing leading `/' from member names
2020-11-11 20:13:20 +0000 UTC info: Update module output: tar: /home/pi/dir_overlay/etc/app.conf: Cannot stat: No such file or directory
2020-11-11 20:13:20 +0000 UTC info: Update module output: tar: Exiting with failure status due to previous errors
2020-11-11 20:13:20 +0000 UTC info: Update module output: + tar -cpf - /home/pi/dir_overlay/usr/bin/app
2020-11-11 20:13:20 +0000 UTC info: Update module output: + cd /var/lib/mender/modules/v3/payloads/0000/tree/tmp/
2020-11-11 20:13:20 +0000 UTC info: Update module output: + tar -xpf -
2020-11-11 20:13:20 +0000 UTC info: Update module output: tar: Removing leading `/' from member names
2020-11-11 20:13:20 +0000 UTC info: Update module output: tar: /home/pi/dir_overlay/usr/bin/app: Cannot stat: No such file or directory
2020-11-11 20:13:20 +0000 UTC info: Update module output: tar: Exiting with failure status due to previous errors
2020-11-11 20:13:20 +0000 UTC info: Update module output: + tar -cpf - /home/pi/dir_overlay/usr/share/app/data.txt
2020-11-11 20:13:20 +0000 UTC info: Update module output: + cd /var/lib/mender/modules/v3/payloads/0000/tree/tmp/
2020-11-11 20:13:20 +0000 UTC info: Update module output: + tar -xpf -
2020-11-11 20:13:20 +0000 UTC info: Update module output: tar: Removing leading `/' from member names
2020-11-11 20:13:20 +0000 UTC info: Update module output: tar: /home/pi/dir_overlay/usr/share/app/data.txt: Cannot stat: No such file or directory
2020-11-11 20:13:20 +0000 UTC info: Update module output: tar: Exiting with failure status due to previous errors
2020-11-11 20:13:20 +0000 UTC info: Update module output: + tar -cpf /var/lib/mender/dir-overlay-install/backup.tar -C /var/lib/mender/modules/v3/payloads/0000/tree/tmp .
2020-11-11 20:13:20 +0000 UTC info: Update module output: + cat /var/lib/mender/dir-overlay-install/manifest
2020-11-11 20:13:20 +0000 UTC info: Update module output: + rm /home/pi/dir_overlay/etc/app.conf
2020-11-11 20:13:20 +0000 UTC info: Update module output: rm: cannot remove '/home/pi/dir_overlay/etc/app.conf': No such file or directory
2020-11-11 20:13:20 +0000 UTC error: Update module terminated abnormally: exit status 1
2020-11-11 20:13:20 +0000 UTC error: transient error: Update module terminated abnormally: exit status 1
2020-11-11 20:13:20 +0000 UTC info: State transition: update-install [ArtifactInstall] -> rollback [ArtifactRollback]
2020-11-11 20:13:20 +0000 UTC info: Performing rollback
2020-11-11 20:13:20 +0000 UTC info: Update module output: + STATE=ArtifactRollback
2020-11-11 20:13:20 +0000 UTC info: Update module output: + FILES=/var/lib/mender/modules/v3/payloads/0000/tree
2020-11-11 20:13:20 +0000 UTC info: Update module output: + backup_dir=/var/lib/mender/modules/v3/payloads/0000/tree/tmp
2020-11-11 20:13:20 +0000 UTC info: Update module output: + dest_dir_file=/var/lib/mender/modules/v3/payloads/0000/tree/files/dest_dir
2020-11-11 20:13:20 +0000 UTC info: Update module output: + manifest_file_from_deployment=/var/lib/mender/modules/v3/payloads/0000/tree/files/manifest
2020-11-11 20:13:20 +0000 UTC info: Update module output: + update_files_tar=/var/lib/mender/modules/v3/payloads/0000/tree/files/update.tar
2020-11-11 20:13:20 +0000 UTC info: Update module output: + state_dir=/var/lib/mender/dir-overlay-install
2020-11-11 20:13:20 +0000 UTC info: Update module output: + manifest_file=/var/lib/mender/dir-overlay-install/manifest
2020-11-11 20:13:20 +0000 UTC info: Update module output: + manifest_file_prev=/var/lib/mender/dir-overlay-install/manifest.prev
2020-11-11 20:13:20 +0000 UTC info: Update module output: + prev_files_tar=/var/lib/mender/dir-overlay-install/backup.tar
2020-11-11 20:13:20 +0000 UTC info: Update module output: + [-n]
2020-11-11 20:13:20 +0000 UTC info: Update module output: + id -u
2020-11-11 20:13:20 +0000 UTC info: Update module output: + UID=0
2020-11-11 20:13:20 +0000 UTC info: Update module output: + [0 -ne 0]
2020-11-11 20:13:20 +0000 UTC info: Update module output: + cat /var/lib/mender/modules/v3/payloads/0000/tree/files/dest_dir
2020-11-11 20:13:20 +0000 UTC info: Update module output: + dest_dir=/home/pi/dir_overlay
2020-11-11 20:13:20 +0000 UTC info: Update module output: + test -f /var/lib/mender/dir-overlay-install/backup.tar
2020-11-11 20:13:20 +0000 UTC info: Update module output: + cp /var/lib/mender/dir-overlay-install/manifest.prev /var/lib/mender/dir-overlay-install/manifest
2020-11-11 20:13:20 +0000 UTC info: Update module output: cp: cannot stat '/var/lib/mender/dir-overlay-install/manifest.prev': No such file or directory
2020-11-11 20:13:20 +0000 UTC error: Update module terminated abnormally: exit status 1
2020-11-11 20:13:20 +0000 UTC error: Rollback failed: Update module terminated abnormally: exit status 1
2020-11-11 20:13:20 +0000 UTC error: fatal error: Update module terminated abnormally: exit status 1
2020-11-11 20:13:20 +0000 UTC info: State transition: rollback [ArtifactRollback] -> update-error [ArtifactFailure]
2020-11-11 20:13:20 +0000 UTC info: Update module output: + STATE=ArtifactFailure
2020-11-11 20:13:20 +0000 UTC info: Update module output: + FILES=/var/lib/mender/modules/v3/payloads/0000/tree
2020-11-11 20:13:20 +0000 UTC info: Update module output: + backup_dir=/var/lib/mender/modules/v3/payloads/0000/tree/tmp
2020-11-11 20:13:20 +0000 UTC info: Update module output: + dest_dir_file=/var/lib/mender/modules/v3/payloads/0000/tree/files/dest_dir
2020-11-11 20:13:20 +0000 UTC info: Update module output: + manifest_file_from_deployment=/var/lib/mender/modules/v3/payloads/0000/tree/files/manifest
2020-11-11 20:13:20 +0000 UTC info: Update module output: + update_files_tar=/var/lib/mender/modules/v3/payloads/0000/tree/files/update.tar
2020-11-11 20:13:20 +0000 UTC info: Update module output: + state_dir=/var/lib/mender/dir-overlay-install
2020-11-11 20:13:20 +0000 UTC info: Update module output: + manifest_file=/var/lib/mender/dir-overlay-install/manifest
2020-11-11 20:13:20 +0000 UTC info: Update module output: + manifest_file_prev=/var/lib/mender/dir-overlay-install/manifest.prev
2020-11-11 20:13:20 +0000 UTC info: Update module output: + prev_files_tar=/var/lib/mender/dir-overlay-install/backup.tar
2020-11-11 20:13:20 +0000 UTC info: Update module output: + [-n]
2020-11-11 20:13:20 +0000 UTC info: Update module output: + id -u
2020-11-11 20:13:20 +0000 UTC info: Update module output: + UID=0
2020-11-11 20:13:20 +0000 UTC info: Update module output: + exit 0
2020-11-11 20:13:20 +0000 UTC info: State transition: update-error [ArtifactFailure] -> cleanup [Error]
2020-11-11 20:13:20 +0000 UTC info: Update module output: + STATE=Cleanup
2020-11-11 20:13:20 +0000 UTC info: Update module output: + FILES=/var/lib/mender/modules/v3/payloads/0000/tree
2020-11-11 20:13:20 +0000 UTC info: Update module output: + backup_dir=/var/lib/mender/modules/v3/payloads/0000/tree/tmp
2020-11-11 20:13:20 +0000 UTC info: Update module output: + dest_dir_file=/var/lib/mender/modules/v3/payloads/0000/tree/files/dest_dir
2020-11-11 20:13:20 +0000 UTC info: Update module output: + manifest_file_from_deployment=/var/lib/mender/modules/v3/payloads/0000/tree/files/manifest
2020-11-11 20:13:20 +0000 UTC info: Update module output: + update_files_tar=/var/lib/mender/modules/v3/payloads/0000/tree/files/update.tar
2020-11-11 20:13:21 +0000 UTC info: Update module output: + state_dir=/var/lib/mender/dir-overlay-install
2020-11-11 20:13:21 +0000 UTC info: Update module output: + manifest_file=/var/lib/mender/dir-overlay-install/manifest
2020-11-11 20:13:21 +0000 UTC info: Update module output: + manifest_file_prev=/var/lib/mender/dir-overlay-install/manifest.prev
2020-11-11 20:13:21 +0000 UTC info: Update module output: + prev_files_tar=/var/lib/mender/dir-overlay-install/backup.tar
2020-11-11 20:13:21 +0000 UTC info: Update module output: + [-n]
2020-11-11 20:13:21 +0000 UTC info: Update module output: + id -u
2020-11-11 20:13:21 +0000 UTC info: Update module output: + UID=0
2020-11-11 20:13:21 +0000 UTC info: Update module output: + exit 0
2020-11-11 20:13:21 +0000 UTC info: State transition: cleanup [Error] -> update-status-report [none] 

```

Saman

@drewmoseley - edited for formatting

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [November 11, 2020, 9:58pm UTC](https://hub.mender.io/t/state-script-support-in-dir-overlay-update-module/915/14 "2020-11-11T21:58:46Z")

</div>

How are you generating the artifact you are installing? Can you include a complete shell log showing the commands you enter and the output they generate?

---

<div class="post-metadata">

**Author:** ![SamanRatna](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@SamanRatna](https://hub.mender.io/u/SamanRatna)\
**Post date:** [November 12, 2020, 2:15am UTC](https://hub.mender.io/t/state-script-support-in-dir-overlay-update-module/915/15 "2020-11-12T02:15:22Z")

</div>

saman@saman-VirtualBox:~/Downloads/Yatri$ ARTIFACT\_NAME=“my-update-1.5”  
saman@saman-VirtualBox:~/Downloads/Yatri$ DEVICE\_TYPE=“raspberrypi3”  
saman@saman-VirtualBox:~/Downloads/Yatri$ OUTPUT\_PATH=“my-update-1.5.mender”  
saman@saman-VirtualBox:~/Downloads/Yatri$ DEST\_DIR="/home/pi/dir\_overlay"  
saman@saman-VirtualBox:~/Downloads/Yatri$ OVERLAY\_TREE=“rootfs\_overlay”  
saman@saman-VirtualBox:~/Downloads/Yatri$ ./dir-overlay-artifact-gen -n {ARTIFACT\_NAME} -t {DEVICE\_TYPE} -d {DEST\_DIR} -o {OUTPUT\_PATH} ${OVERLAY\_TREE}  
Artifact my-update-1.5.mender generated successfully:  
Mender artifact:  
Name: my-update-1.5  
Format: mender  
Version: 3  
Signature: no signature  
Compatible devices: ‘[raspberrypi3]’  
Provides group:  
Depends on one of artifact(s): []  
Depends on one of group(s): []  
State scripts:

Updates:  
0:  
Type: dir-overlay  
Provides: Nothing  
Depends: Nothing  
Metadata: Nothing  
Files:  
name: update.tar  
size: 10240  
modified: 2020-11-12 02:53:30 +0545 +0545  
checksum: 44118099007e657c54cc86add38d3a7d167a14d52456be79c4fe9a5afdd3516f  
Files:  
name: dest\_dir  
size: 21  
modified: 2020-11-12 02:53:30 +0545 +0545  
checksum: 3b73f45ef3bb0148064a24f4af80f1213cfda08e0960f82a4ae1f96bee9ee710  
Files:  
name: manifest  
size: 48  
modified: 2020-11-12 02:53:30 +0545 +0545  
checksum: 8ffe642007fbdcfdb2617e709c6091d84bf510e2235c584134240ed922dd4185

---

<div class="post-metadata">

**Author:** ![SamanRatna](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@SamanRatna](https://hub.mender.io/u/SamanRatna)\
**Post date:** [November 12, 2020, 3:58am UTC](https://hub.mender.io/t/state-script-support-in-dir-overlay-update-module/915/16 "2020-11-12T03:58:08Z")

</div>

> [@SamanRatna](#):
>
> DEST\_DIR=“/home/pi/dir\_overlay”

When I set my DEST\_DIR to “/”, the deployment succeeds. I am not sure why I fail on /home/pi/dir\_overlay even though I have set the permission to 755 on both locations.

After the deployment succeeds, I am confused about what sort of output I should expect. After having used directory update and single-file update, I was expecting the overlaying directory to be located on the DEST\_DIR, with its subdirectories. I can’t find rootfs\_overlay directory anywhere on my device. Instead, I see backup.tar, manifest, and manifest.prev files at location /var/lib/mender/dir-overlay-install. When I extract the tar file, I could find the overlaying directories. Is it the way how dir-overlay works or am I missing out something?

Regards,  
Saman

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [November 12, 2020, 6:33pm UTC](https://hub.mender.io/t/state-script-support-in-dir-overlay-update-module/915/17 "2020-11-12T18:33:26Z")

</div>

The files in `/var/lib/mender/dir-overlay-install` are state files and backups which is how the update module is able to handle rollback.

I don’t believe you will see a directory named `rootfs_overlay/` but the contents from that directory should appear directly in your `DEST_DIR`.

Drew

---

<div class="post-metadata">

**Author:** ![SamanRatna](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@SamanRatna](https://hub.mender.io/u/SamanRatna)\
**Post date:** [November 13, 2020, 4:10pm UTC](https://hub.mender.io/t/state-script-support-in-dir-overlay-update-module/915/18 "2020-11-13T16:10:38Z")

</div>

Thanks @drewmoseley
