Directory

Hi, I was wondering if there is any way to update the directory without deleting unwanted items. For instance I am updating a directory that contains all the executables along with the user data. I want to update the exes but I dont want any user data to be removed. I created a mender artifact with only exes but its deleting any user data previously on that directory as well. Would be thankful for any feed. Thanks

You may want to look at the Directory Overlay module.

1 Like

Hi @drewmoseley. I tried Mender Directory Overlay module. My Mender Client version is 2.2 and mender-artifact I am using is 3.1.1. When trying to deploy the artifact I am getting this error

" Artifact Payload type ‘dir-overlay’ is not supported by this Mender Client"

According the the example provided it is supposed to be working with these version but I am somehow failing to do so. Can you please provide some insight

PS: I am not trying to overlay rootfs. I am trying it with for a custom directory in the home folder.

Thanks

It sounds like you don’t have the update module itself installed on the client. To do that manually, run the following:

mkdir -p /usr/share/mender/modules/v3 && wget -P /usr/share/mender/modules/v3 https://raw.githubusercontent.com/mendersoftware/mender-update-modules/master/dir-overlay/module/dir-overlay && chmod +x /usr/share/mender/modules/v3/dir-overlay

Thanks it worked.

Hello,

Can I use the same directory update module to create new directories in persistent data section(/data)?

Yes, the target directory is specified as a parameter and can be anywhere.

So I did create an application update using the below parameters.

ARTIFACT_NAME=“My-Test-Update-1.0”
DEVICE_TYPE=“raspberrypi-cm3”
OUTPUT_PATH=“My-Test-Update-1.0.mender”
DEST_DIR="/data/"
FILE_TREE=“system”
./directory-artifact-gen -n {ARTIFACT_NAME} -t {DEVICE_TYPE} -d {DEST_DIR} -o {OUTPUT_PATH} ${FILE_TREE}

But the application update is stuck at 69%. Am I missing something?

Edit1: It has been stuck at 69% for about 2 hours now

Can you provide output from journalctl -u mender-client on the device?

journalctl replied back saying no new entries. But the application update failed and the error is

2020-09-15 13:41:41 +0000 UTC error: Fetching Artifact headers failed: installer: failed to read Artifact: readHeaderV3: handleHeaderReads: Artifact Payload type 'directory' is not supported by this Mender Client

It feels like I need to add something in my local.conf

Maybe you are missing:

PACKAGECONFIG_pn-mender-client = " modules"

This could also go into a bbappend file for mender-client.

Hi all, Is there any way to execute script after uploading files to client? To clarify my question, below is the explanation with an example:
Let’s say I have three files, out of which one is script (.sh file) and other two are package files of an application and want to install that packages using that script.
Is it possible? How to create artifact for this scenario?
Please guide me on this?
May be its a silly question but I am very new to mender, and struggling with this scenario since past couple of months. Currently I am uploading file using directory module to the client first. Then executing a script using script module. For that I am creating a two different artifacts and uploading it to client through server.
But now I want this to be done with only one artifact. Please guide me on this.

Thanks!

Hi @hitesh53G,

There are different ways to achieve “installing and executing something” in one Artifact. An simple way could be to use the directory Update Module (installing the two package files) while shipping the script as an state script in the Artifact.

The state scripts are scripts that are executed as part of the update process at different stages. You can find more information in the documentation of Mender Artifacts state scripts.

Hi @lluiscampos,
Thanks for your reply. I am trying the way you have suggested. I have read the document but still not getting that how to get it done. Do you have example link on same scenario. So going through an example may be help me to understand the concept.

Thanks!

If you are trying to figure out how to build 1 artifact that includes your package install script and the 2 packages see this post Mender-convert - Include state scripts in the artifact

You can put everything into the artifact using the directory module and mender-artifact cmd. Mender-client runs scripts if they match certain names @lluiscampos mentioned in the link https://docs.mender.io/artifact-creation/state-scripts#transitions-and-ordering e.g. ArtifactInstall_Leave_01_install_hitesh53G_pkg

I want to test out the artifact fail scenario to make sure my system can handle error recovery from a bad update.

What is the simplest way to create an artifact that will always fail for the Directory module?

  1. Create ArtifactInstall_Leave script that returns 1
  2. create artifact that copies to dest directory that does not exist

Thanks!

I think I’d do 1), except I’d fail in the Enter state :slight_smile:

But both solutions work just fine.

1 Like

@hitesh53G And for anyone else that isn’t sure how to add scripts to an artifact using the Directory module. I guess it would work for any update module. One variable per script, add as many as you need

SCRIPT1="<path to script>/ArtifactInstall_Enter_01_do_something" 

SCRIPT2="<path to script>/ArtifactInstall_Leave_01_do_something_else" 

./directory-artifact-gen -n ${ARTIFACT_NAME} -t ${DEVICE_TYPE} -d ${DEST_DIR} -o ${OUTPUT_PATH} ${FILE_TREE} -- --script ${SCRIPT1} --script ${SCRIPT2}

@oleorhagen Thanks for the suggestion!

1 Like

Hi all !
I’m writing to you because we are trying to use the Directory Update Module to update our configuration files but we are encountering some error:

INFO[0000] Loaded configuration file: /var/lib/mender/mender.conf
INFO[0000] Loaded configuration file: /etc/mender/mender.conf
INFO[0000] Mender running on partition: /dev/mmcblk0p1
ERRO[0000] Failed to Load the Server certificate. Err SSL errors:
WARN[0000] Failed to load the server TLS certificate settings: SSL errors:
INFO[0000] Start updating from local image file: [conf-v25.mender]
Installing Artifact of size 8192...
INFO[0000] No public key was provided for authenticating the artifact
.....................                                          -  34 %ERRO[0000] Reading headers failed: open /etc/mender/artifact_info: no such file or directory
ERRO[0000] open /etc/mender/artifact_info: no such file or directory

We manage to sucessfully create artifacts with directory-artifact-gen but we fail to install them, either in standalone or server mode. We don’t have any problem installing rootfs Artifacts.
We are using a read-only rootfs and Mender 2.6.0 (same problem with Mender 3.0.0)

If I understand correctly, the artifact_info file is not supposed to be used anymore, so why it is still looking for it ?

Any help would be appreciated,

Thanks !

1 Like

Hey @VivFlo

While it’s true this file is in the process of being deprecated, the transition is not complete yet, so it is still required for the very first update. Afterwards it is ignored. Once this ticket is fixed, the file can be removed completely.