From 3d6707747e2cc6b76221c65f3c2fbdfec311071d Mon Sep 17 00:00:00 2001 From: Lluis Campos Date: Wed, 6 Feb 2019 15:38:48 +0100 Subject: [PATCH 1/2] MEN-2248: Document missing options in the scripts Changelog: Title Signed-off-by: Lluis Campos --- convert-stage-4.sh | 5 ++++- mender-convert | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/convert-stage-4.sh b/convert-stage-4.sh index 6db352f..b4c0cab 100755 --- a/convert-stage-4.sh +++ b/convert-stage-4.sh @@ -9,7 +9,7 @@ Usage: $0 [options] Options: [-m|--mender-disk-image | -g|--mender-client | -a|--artifact-name | -d|--device-type | -p|--demo-host-ip | -u| --server-url | - -t| --tenant-token] + -c|--server-cert -t| --tenant-token -k|--keep -h|--help] --mender-disk-image - Mender raw disk image --mender-client - Mender client binary file @@ -18,6 +18,9 @@ Usage: $0 [options] --demo-host-ip - Mender demo server IP address --server-url - Mender production server url --server-cert - Mender server certificate + --tenant-token - Mender tenant token + --keep - Keep intermediate files in output directory + --help - Show help and exit Examples: diff --git a/mender-convert b/mender-convert index 8d8f19f..22ac8e1 100755 --- a/mender-convert +++ b/mender-convert @@ -36,7 +36,7 @@ Options: [-r|--raw-disk-image | -m|--mender-disk-image | -s|--data-part-size-mb -d|--device-type | -p|--rootfs-partition-id | -i|--demo-host-ip | -c|--server-cert | -u|--server-url | -t|--tenant-token | -g|--mender-client | -b|--bootloader-toolchain | -a|--artifact-name | - -e|--storage-total-size-mb | -k|--keep | -v|--version] + -e|--storage-total-size-mb | -k|--keep | -v|--version -h|--help] raw-disk-image - raw disk embedded Linux (Debian, Raspbian, Ubuntu, etc.) image path @@ -58,6 +58,7 @@ Options: [-r|--raw-disk-image | -m|--mender-disk-image | -s|--data-part-size-mb it is used to calculate the rootfs final size keep - keep intermediate files in output directory version - print the version + help - show help and exit Note: root filesystem size used in Mender image creation can be found as an output from 'raw-disk-image-shrink-rootfs' command or, in case From 151eb4d784b4db28f3baf95f52298b642f9122c6 Mon Sep 17 00:00:00 2001 From: Lluis Campos Date: Thu, 7 Feb 2019 12:38:13 +0100 Subject: [PATCH 2/2] MEN-2248: Set production/demo intervals conditionally Select demo default intervals with new --demo CLI option, else use production defaults (updated in parallel in MEN-2248) Changelog: Title Signed-off-by: Lluis Campos --- convert-stage-4.sh | 28 ++++++++++++++++++++++++---- mender-convert | 11 ++++++++++- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/convert-stage-4.sh b/convert-stage-4.sh index b4c0cab..eb32e56 100755 --- a/convert-stage-4.sh +++ b/convert-stage-4.sh @@ -8,13 +8,14 @@ Mender executables, service and configuration files installer. Usage: $0 [options] Options: [-m|--mender-disk-image | -g|--mender-client | -a|--artifact-name | - -d|--device-type | -p|--demo-host-ip | -u| --server-url | + -d|--device-type | -n|--demo | -p|--demo-host-ip | -u| --server-url | -c|--server-cert -t| --tenant-token -k|--keep -h|--help] --mender-disk-image - Mender raw disk image --mender-client - Mender client binary file --artifact-name - artifact info --device-type - target device type identification + --demo - Configure image using demo parameters --demo-host-ip - Mender demo server IP address --server-url - Mender production server url --server-cert - Mender server certificate @@ -70,6 +71,16 @@ create_client_files() { rootfspartb="/dev/hda3" fi + # Default polling intervals for Production + local updatePollInterval="1800" + local inventPollInterval="28800" + local retryPollInterval="300" + if [ -n "${demo}" ] && [ ${demo} -eq 1 ]; then + updatePollInterval="5" + inventPollInterval="5" + retryPollInterval="30" + fi + cat <<- EOF > $mender_dir/mender.service [Unit] Description=Mender OTA update service @@ -90,14 +101,14 @@ create_client_files() { cat <<- EOF > $mender_dir/mender.conf { - "InventoryPollIntervalSeconds": 5, - "RetryPollIntervalSeconds": 30, + "InventoryPollIntervalSeconds": "$inventPollInterval", + "RetryPollIntervalSeconds": "$retryPollInterval", "RootfsPartA": "$rootfsparta", "RootfsPartB": "$rootfspartb", "ServerCertificate": "/etc/mender/server.crt", "ServerURL": "$mender_server_url", "TenantToken": "$mender_tenant_token", - "UpdatePollIntervalSeconds": 5 + "UpdatePollIntervalSeconds": "$updatePollInterval" } EOF @@ -261,6 +272,11 @@ do_install_mender() { show_help fi + if [ -n "${demo}" ] && [ ${demo} -eq 1 ] && [ -z "${demo_host_ip}" ]; then + log "Demo configuration requires demo_host_ip. Aborting." + show_help + fi + # TODO: more error checking of server types if [ -n "${tenant_token}" ]; then mender_tenant_token=$(echo ${tenant_token} | tr -d '\n') @@ -336,6 +352,10 @@ while (( "$#" )); do artifact_name=$2 shift 2 ;; + -n | --demo) + demo="1" + shift 1 + ;; -i | --demo-host-ip) demo_host_ip=$2 shift 2 diff --git a/mender-convert b/mender-convert index 22ac8e1..fe2ffe2 100755 --- a/mender-convert +++ b/mender-convert @@ -33,7 +33,7 @@ Expert commands: related files Options: [-r|--raw-disk-image | -m|--mender-disk-image | -s|--data-part-size-mb | - -d|--device-type | -p|--rootfs-partition-id | -i|--demo-host-ip | + -d|--device-type | -p|--rootfs-partition-id | -n|--demo | -i|--demo-host-ip | -c|--server-cert | -u|--server-url | -t|--tenant-token | -g|--mender-client | -b|--bootloader-toolchain | -a|--artifact-name | -e|--storage-total-size-mb | -k|--keep | -v|--version -h|--help] @@ -47,6 +47,7 @@ Options: [-r|--raw-disk-image | -m|--mender-disk-image | -s|--data-part-size-mb Mender image rootfs-partition-id - selects root filesystem (primary|secondary) as the source filesystem for an artifact + demo - Configure image using demo parameters demo-host-ip - server demo ip used for testing purposes server-cert - server certificate file server-url - production server url @@ -461,6 +462,10 @@ do_install_mender_to_mender_disk_image() { # mender-image-1.5.0 stage_4_args="-m $mender_disk_image -d $device_type -g ${mender_client} -a ${artifact_name}" + if [ -n "$demo" ] && [ ${demo} -eq 1 ]; then + stage_4_args="${stage_4_args} --demo" + fi + if [ -n "$demo_host_ip" ]; then stage_4_args="${stage_4_args} -i ${demo_host_ip}" fi @@ -734,6 +739,10 @@ while (( "$#" )); do bootloader_toolchain=$2 shift 2 ;; + -n | --demo) + demo="1" + shift 1 + ;; -i | --demo-host-ip) demo_host_ip=$2 shift 2