# Is there an example for building an image of a directory that runs a script afterwards?

**URL:** <https://hub.mender.io/t/is-there-an-example-for-building-an-image-of-a-directory-that-runs-a-script-afterwards/3716>\
**Category:** General Discussions\
**Created:** [June 6, 2021, 8:28pm UTC](https://hub.mender.io/t/is-there-an-example-for-building-an-image-of-a-directory-that-runs-a-script-afterwards/3716 "2021-06-06T20:28:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChocolatePie](https://avatars.discourse-cdn.com/v4/letter/c/e79b87/32.png) [@ChocolatePie](https://hub.mender.io/u/ChocolatePie)\
**Post date:** [June 6, 2021, 8:28pm UTC](https://hub.mender.io/t/is-there-an-example-for-building-an-image-of-a-directory-that-runs-a-script-afterwards/3716/1 "2021-06-06T20:28:54Z")

</div>

hey everyone,

There is a [write up](https://hub.mender.io/t/directory/325) on how to create a directory module and how to enable the target device to receive to it.

There is also a [write up](https://hub.mender.io/t/script/328) on how to create a script executing module and how to enable the target device to receive to it.

I tried to combine both of these example into a single module that would download directory onto the target device and then it would run a script responsible for building binaries.

Does there exist an already designed module build script that accomplishes that or a tutorial/write up to do so?

regards

cp

---

<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:** [June 6, 2021, 9:45pm UTC](https://hub.mender.io/t/is-there-an-example-for-building-an-image-of-a-directory-that-runs-a-script-afterwards/3716/2 "2021-06-06T21:45:27Z")

</div>

Hi @ChocolatePie I’m not aware of anything that documents precisely that. I think your best approach is to use the directory module with an appropriate [state script](https://docs.mender.io/overview/state-script) to do the building after the directory is installed.

Drew
