blob: 3df85785ceb4ff8b2424c425ca794d2a74b315c9 (
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
33
34
35
36
37
|
#!/bin/bash
#
# Detect Virtualization:
#
model="CP2.*"
spi_flash_model="mx25l25635e"
interface=xyz.openbmc_project.FruDevice
asset_tag_var=PRODUCT_ASSET_TAG
# no more than 20 chars:
# ---------------------
asset_tag_vm='"Virtual BMC"'
asset_tag_hw='"BMC"'
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}"
}
get_asset_tag() {
local tag=$(run_cmd /usr/bin/busctl get-property ${interface} $(get_model_path) ${interface} ${asset_tag_var} | sed 's,^s "\([^"]*\)",\1,')
echo "${tag}"
}
if `dmesg | grep -q "aspeed-smc 1e620000.spi: ${spi_flash_model}"` ; then
run_cmd /usr/bin/busctl set-property ${interface} $(get_model_path) ${interface} ${asset_tag_var} s ${asset_tag_vm}
else
if [ "$(get_asset_tag)" = "...................." ] ; then
run_cmd /usr/bin/busctl set-property ${interface} $(get_model_path) ${interface} ${asset_tag_var} s ${asset_tag_hw}
fi
fi
|