kumquat-buildroot/package/mender/mender-device-identity
Angelo Compagnucci 6ed0e6ba23 package/mender: new package
This patch add mender, an open source over-the-air (OTA) software
updater for embedded Linux devices.

Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
[Thomas:
 - add entry to DEVELOPERS file.
 - drop dependency on systemd, since there is really no build
   dependency, it's just that the init script integration is missing.
 - add Config.in comment about the thread dependency
 - don't override install commands, otherwise the mender binary is not
   installed, and instead use a post install target hook.]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2018-06-05 21:43:42 +02:00

53 lines
1.3 KiB
Bash

#!/bin/sh
# Example script called by Mender agent to collect device identity data. The
# script needs to be located at
# $(datadir)/mender/identity/mender-device-identity path for the agent to find
# it. The script shall exit with non-0 status on errors. In this case the agent
# will discard any output the script may have produced.
#
# The script shall output identity data in <key>=<value> format, one
# entry per line. Example
#
# $ ./mender-device-identity
# mac=de:ad:ca:fe:00:01
# cpuid=1112233
#
# The example script collects the MAC address of a network interface with the
# type ARPHRD_ETHER and it will pick the interface with the lowest ifindex
# number if there are multiple interfaces with that type. The identity data is
# output in the following format:
#
# mac=00:01:02:03:04:05
#
set -ue
SCN=/sys/class/net
min=65535
arphrd_ether=1
ifdev=
# find iface with lowest ifindex, skip non ARPHRD_ETHER types (lo, sit ...)
for dev in $SCN/*; do
iftype=$(cat $dev/type)
if [ $iftype -ne $arphrd_ether ]; then
continue
fi
idx=$(cat $dev/ifindex)
if [ $idx -lt $min ]; then
min=$idx
ifdev=$dev
fi
done
if [ -z "$ifdev" ]; then
echo "no suitable interfaces found" >&2
exit 1
else
echo "using interface $ifdev" >&2
# grab MAC address
echo "mac=$(cat $ifdev/address)"
fi