Mender state script for debian

Hello everyone,
when using the mender-convert-2.0.0, i included inside my overlay a simple state script that would only allow the RPI to reboot between a certain timeframe.
however when i deploy the same again (but with a different name)
the state script inside this rootfs does not wait until the appropriate time & the device just reboots and fails to boot up.
when making an artifact of that same image but without the state scripts, i does boot up, but not state scripts are triggered, even tough the state script was available in that rootfs
Here you can see the difference between the two when using an overlay for the mender-convert ↓

the state script itself is just a simple time checker

#!/bin/sh
OK=0
LATER=21
H=$(date +%k)
if [ $H -lt 22 ]; then
           exit ${LATER}
fi
exit ${OK}

At this point i’m just assuming im implementing it wrong, i am aware of this post made a while back, but this was with the older mender-convert in mind and therefore the use of the mender-artifact was needed.
I assume, that as long that the state scripts are available in /etc/mender/scripts/NameScript of the rootfs, they most work

Greetings Gene

Hi,

Note that state-scripts can be put in two different locations as described here,

https://docs.mender.io/2.3/artifacts/state-scripts#root-file-system-and-artifact-scripts

All states that start with Artifact* indicate that the state-script should be part of the Artifact and not the rootfs.

This is added when creating the artifact using the -s / --script argument:

mender-artifact write rootfs-image --help | grep script
   --script value, -s value                 Full path to the state script(s). You can specify multiple scripts providing this parameter multiple times.

1 Like

Hi @mirzak,
thanks for clarifying i was not aware that some state scripts were only for artifact usage

meant as a follow up,

after using the right state script for rootfs usage, the scripts where still not working, this however is because i used the mender 2.0.0 overlay to add the state scripts.
mender expects in /etc/mender/scripts also a file called ‘version’ as noted here, this file is not added when using the mender convert overlay as i did, after adding this everything works fine.

example ↓
version

Thanks for mentioning that @genedupre, this has been fixed in the master branch of mender-convert.

Drew