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?
- Create ArtifactInstall_Leave script that returns 1
- 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
But both solutions work just fine.
@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!
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 !
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.
I tried both this and the Directory Overlay module update instructions to simply overwrite a directory with a directory, and they say âDownloadingâŚâ then âInstallingâŚâ then seem to get stuck in this state indefinitely. (On a Mender deployment of the generated artifact)
Any idea if your script is out of date?
Thanks.
Having the exact same issue
Hello @EnjoysMath ,
This is interesting. I am not aware of the module being âout of dateâ, in the sense that the API has not been modified and it should work.
Can you provide the logs from the device? For example logging in into the device after getting stuck, and executing:
journalctl -u mender-client | cat
LluĂs
I recently had trouble with this directory update module. And I think I found a serious bug. Iâll copy the current (relevant) code of the module here for reference
[...]
case "$STATE" in
[...]
ArtifactInstall)
dest_dir=$(cat $dest_dir_file)
test -z "$dest_dir" && \
echo "Fatal error: dest_dir is undefined." && exit 1
test "$dest_dir" = "/" && \
echo "Error: destination dir is '/', install not supported." && exit 1
mkdir -p $dest_dir
if ! tar -cf ${prev_files_tar} -C ${dest_dir} . # <-- might fail
then
ret=$?
# Make sure there is no half-backup lying around.
rm -f ${prev_files_tar}
exit $ret
fi
rm -rf ${dest_dir}
mkdir -p ${dest_dir}
tar -xf ${update_files_tar} -C ${dest_dir} # <-- might fail
;;
[...]
esac
exit 0
The issue arose, when our target device was low on disk space. When deploying the artifact there are two lines in the script that might fail due to space limitations. Both marked above.
The concerning part is, even if the extraction of the archive fails, the script will exit with a 0. That results in the failure not being propagated and the deployment will be reported as successful, even though it has failed, and even more it might leave a corrupted version of the updated directory behind.
So in the end it might crash the application while still reporting a successful deployment.
I altered the code as follows:
[...]
ArtifactInstall)
dest_dir=$(cat $dest_dir_file)
test -z "$dest_dir" && \
echo "Fatal error: dest_dir is undefined." && exit 1
test "$dest_dir" = "/" && \
echo "Error: destination dir is '/', install not supported." && exit 1
mkdir -p $dest_dir
tar -cf ${prev_files_tar} -C ${dest_dir} .
createPrevSuccess=$?
if [ $createPrevSuccess -ne 0 ]
then
echo "Fatal error: Unable to create backup"
# Make sure there is no half-backup lying around.
rm -f ${prev_files_tar}
exit $createPrevSuccess
fi
rm -rf ${dest_dir}
mkdir -p ${dest_dir}
tar -xf ${update_files_tar} -C ${dest_dir}
extractSuccess=$?
if [ $extractSuccess -ne 0 ]
then
echo "Fatal error: something went wrong during artifact installation"
exit $extractSuccess
fi
;;
[...]
Has anybody else encountered that issue?
care to pour this into a pull request on GitHub? We discuss and review code contributions there.
Greets,
Josef
@TheYoctoJester sure, done.