Skip to content

librescoot/smut

Repository files navigation

Simple Mender Update Tool (SMUT)

A lightweight daemon for managing Mender updates on embedded Linux systems via Redis.

Overview

SMUT runs on embedded Linux systems (MDB and DBC) and triggers Mender updates via Redis. It handles resumable downloads, checksum verification, and interacts with Mender.

Features

  • Redis BLPOP for update requests
  • Resumable downloads with retry
  • Checksum verification (SHA256)
  • Support for file:// URLs for local file installation
  • Automatic Mender update install and commit
  • Error reporting via Redis
  • Cross-compilation for armv7l
  • No CGO

Requirements

  • Go 1.16+ (for building)
  • Redis server
  • Mender update client (mender-update in PATH)
  • Linux (armv7l target)

Building

For Local Development

make

For ARM Target (armv7l)

make build-arm

Clean Build

make clean build

Installation

The project includes an installer script that handles deployment to both MDB and DBC systems.

  1. Build the ARM binary:
make build-arm
  1. Run the installer:
./install.sh <target-host> <target>

Where:

  • target-host: The hostname/IP of the MDB system
  • target: One of:
    • mdb: Install only on MDB
    • dbc: Install only on DBC
    • both: Install on both MDB and DBC

The installer handles:

  • Copying files to target systems
  • Service installation and configuration
  • GPIO management for DBC communication
  • Service startup and verification

Usage

Command-Line Arguments

  • --redis-addr: Redis server address (default: "localhost:6379")
  • --update-key: Redis key for update URLs (default: "mender/update/url")
  • --checksum-key: Redis key for checksums (default: "mender/update/checksum")
  • --failure-key: Redis key to set on failure (default: "mender/update/last-failure")
  • --download-dir: Directory to store downloaded update files (default: "/tmp")
  • --update-type: Type of update ('blocking' for DBC, 'non-blocking' for MDB) (default: "non-blocking")

Redis Usage

SMUT uses the ota Redis hash to report status and update type. The status field indicates the current state, and the update-type field indicates if the update is blocking or non-blocking.

To trigger an update, push the URL to the update key using LPUSH:

# For MDB system with remote file
redis-cli LPUSH mender/update/mdb/url "http://example.com/path/to/update.mender"

# For DBC system with remote file
redis-cli LPUSH mender/update/dbc/url "http://example.com/path/to/update.mender"

# For MDB system with local file
redis-cli LPUSH mender/update/mdb/url "file:///path/to/local/update.mender"

# For DBC system with local file
redis-cli LPUSH mender/update/dbc/url "file:///path/to/local/update.mender"

When using file:// URLs, SMUT will skip the download step and directly use the specified local file for installation. The file path must be absolute and accessible to the SMUT process.

To set a checksum (optional):

# For MDB system
redis-cli SET mender/update/mdb/checksum "sha256:abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"

# For DBC system
redis-cli SET mender/update/dbc/checksum "sha256:abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"

The checksum is optional. If provided, it should be in the format algorithm:hash. Currently, only SHA256 is supported.

Error Reporting

Errors are reported by setting the configured failure key in Redis with the error message as a string. The status field in the ota hash will also be updated to reflect the error state.

Monitoring

Logs

When running as a systemd service, logs can be viewed with:

journalctl -u smut@<system> -f

Replace <system> with mdb or dbc.

Status

Check the service status with:

systemctl status smut@<system>

Replace <system> with mdb or dbc.

License

Affero GPL 3.0

About

Simple Mender Update Tool

Resources

License

Stars

Watchers

Forks

Packages

No packages published