In the previous blog, we explored how to update a single file using Mender OTA while allowing control over its installation. In this follow-up, we will extend that approach to create an update containing both a directory and a Pre-Installation script, enabling more advanced update scenarios.
In this example, we will use the hosted Mender server. Both the update file generation and installation will be performed on the same host to demonstrate the functionality.
Source
You can find all the files discussed in this blog from the repository.
Prerequsites
- Account at Hosted Mender
- Ubuntu 20.04 / 22.04 / 24.04 LTS or Debian 11 / 12 Distribution
You can checkout the previous article for Mender Client Installation.
Generate Artifact (Update File)
-
Create a Project Folder for Generating Artifact
mkdir -p Project/App & cd Project mkdir -p StateScripts
-
Add an example file called metadata.txt
nano App/metadata.txt
VERSION=V1.0.6
Do add additional files to the App folder for demonstration.
-
Create a Pre-Install State Script
nano StateScripts/ArtifactInstall_Enter_00
#!/bin/bash echo "Script Running before installing Directory" exit 0
-
Download the artifact generator and make it executable
wget https://raw.githubusercontent.com/mendersoftware/mender/master/support/modules-artifact-gen/directory-artifact-gen chmod +x directory-artifact-gen
-
Generate Mender Artifact
./directory-artifact-gen --artifact-name Application_V1.0.6 --device-type TestDevices --dest-dir /home/abish/MenderApp --software-version 1.0.6 -o Application_V1.0.6.mender Project/App -- -s Project/StateScripts/ArtifactInstall_Enter_00
Generated Artifact
Create End Directory (Device)
-
Create the directory where the artifact / directory is installed.
mkdir -p /home/abish/MenderApp
Deploy Update
-
Upload Release Package.
In the releases tab of mender, upload the artifact generated.
Upload Artifact -
Create Deployment with the uploaded artifact.
Create Deployment
Note: If you installed the Download Control Bash script (/etc/mender/scripts/Download_Enter_00
) from the previous blog, you must either remove it to avoid control over the update process or run the DownloadControl
Python program to allow the update to proceed.
Check Logs on Device
sudo journalctl -u mender-client.service -f

From the log, it can be observed that the ArtifactInstall_Enter_00
script executed before the directory was deployed.
