Mender-convert - Include state scripts in the artifact

Hi @c3ntry you include root filesystem scripts in /etc/mender/scripts via the overlay but Artifact scripts need to be added into the artifact when mender-artifact is invoked. You can see docs about the different types of scripts here.

To add Artifact scripts with mender-convert, you need to override the mender_create_artifact function with one of your own that adds the appropriate ‘–script value’ options. For reference, the default function is here.

Basically you create your own config file and then add an extra –config my-custom-config to your invocation of mender-convert. The custom config file would look something like:

mender_create_artifact() {
  local -r device_type="${1}"
  local -r artifact_name="${2}"
  local -r image_name="${3}"

  mender_artifact=deploy/${image_name}.mender
  log_info "Writing Mender artifact to: ${mender_artifact}"
  log_info "This can take up to 20 minutes depending on which compression method is used"

  run_and_log_cmd "mender-artifact --compression ${MENDER_ARTIFACT_COMPRESSION} \
      write rootfs-image \
      --file work/rootfs.img \
      --output-path ${mender_artifact} \
      --artifact-name ${artifact_name} \
      --script <full-path-to>/ArtifactReboot_Leave_00_verify-modem-up \
      --device-type ${device_type}"
}

The version file is created automatically by the mender-convert-modify portion of mender-convert.

Drew

1 Like