summaryrefslogtreecommitdiff
path: root/meta-ibs/meta-common/recipes-ibs/firmware-watchdog/firmware-watchdog/set-asset-tag
blob: 7e7d96d1300dfc6b85f938c0710adb2a6fa0847a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
#
# Set AssetTag:
# ============
#

model="CP2.*"
interface=xyz.openbmc_project.FruDevice
asset_tag_var=PRODUCT_ASSET_TAG

tag="${1}"

if [ "x${tag}" = "x" ] ; then
  tag="...................."
fi

# exactly 20 chars:
# ----------------
asset_tag=$(printf "'%*s'" 20 "${tag}")
asset_tag=$(echo "${asset_tag}" | sed 's, ,\.,g')

run_cmd() {
  local cmd="${*}"
  eval $cmd
}

get_model_path() {
  local path=$(/usr/bin/busctl tree ${interface} | grep "/FruDevice/${model}" | sed 's,^[ \t`-]*,,' | sed 's,[ \t]*$,,')
  echo "${path}"
}

run_cmd /usr/bin/busctl set-property ${interface} $(get_model_path) ${interface} ${asset_tag_var} s "${asset_tag}"