diff options
-rw-r--r-- | kvmd/apps/kvmd/info/hw.py | 9 | ||||
-rwxr-xr-x | scripts/kvmd-bootconfig | 23 |
2 files changed, 23 insertions, 9 deletions
diff --git a/kvmd/apps/kvmd/info/hw.py b/kvmd/apps/kvmd/info/hw.py index 1ff61145..2222ace3 100644 --- a/kvmd/apps/kvmd/info/hw.py +++ b/kvmd/apps/kvmd/info/hw.py @@ -70,8 +70,8 @@ class HwInfoSubmanager(BaseInfoSubmanager): cpu_temp, mem, ) = await asyncio.gather( - self.__read_dt_file("model"), - self.__read_dt_file("serial-number"), + self.__read_dt_file("model", upper=False), + self.__read_dt_file("serial-number", upper=True), self.__read_platform_file(), self.__get_throttling(), self.__get_cpu_percent(), @@ -108,11 +108,12 @@ class HwInfoSubmanager(BaseInfoSubmanager): # ===== - async def __read_dt_file(self, name: str) -> (str | None): + async def __read_dt_file(self, name: str, upper: bool) -> (str | None): if name not in self.__dt_cache: path = os.path.join(f"{env.PROCFS_PREFIX}/proc/device-tree", name) try: - self.__dt_cache[name] = (await aiotools.read_file(path)).strip(" \t\r\n\0") + value = (await aiotools.read_file(path)).strip(" \t\r\n\0") + self.__dt_cache[name] = (value.upper() if upper else value) except Exception as err: get_logger(0).error("Can't read DT %s from %s: %s", name, path, err) return None diff --git a/scripts/kvmd-bootconfig b/scripts/kvmd-bootconfig index 06f41dbb..c2fc5c6f 100755 --- a/scripts/kvmd-bootconfig +++ b/scripts/kvmd-bootconfig @@ -50,16 +50,21 @@ fi # shellcheck disable=SC1090 source <(dos2unix < /boot/pikvm.txt) +# shellcheck disable=SC1091 +source /usr/share/kvmd/platform || true + rw # ========== First boot and/or Avahi configuration ========== make_avahi_service() { + local _base local _serial - _serial=$(tr -d '\0' < /proc/device-tree/serial-number || echo "0000000000000000") - local _model - _model=$(tr -d '\0' < /proc/device-tree/model || echo "Unknown model") + local _platform + _base=$(tr -d '\0' < /proc/device-tree/model || echo "Unknown base") + _serial=$( (cat /proc/device-tree/serial-number || echo "0000000000000000") | tr -d '\0' | tr '[:lower:]' '[:upper:]') + _platform="$PIKVM_MODEL-$PIKVM_VIDEO-$PIKVM_BOARD" mkdir -p /etc/avahi/services cat <<end_of_file > /etc/avahi/services/pikvm.service <?xml version="1.0" standalone='no'?> @@ -72,8 +77,12 @@ make_avahi_service() { <txt-record>path=/</txt-record> <txt-record>protocol=https</txt-record> <txt-record>description=PiKVM Web Server</txt-record> + <txt-record>model=$PIKVM_MODEL</txt-record> + <txt-record>video=$PIKVM_VIDEO</txt-record> + <txt-record>board=$PIKVM_BOARD</txt-record> + <txt-record>base=$_base</txt-record> <txt-record>serial=$_serial</txt-record> - <txt-record>model=$_model</txt-record> + <txt-record>platform=$_platform</txt-record> </service> <service> <type>_https._tcp</type> @@ -81,8 +90,12 @@ make_avahi_service() { <txt-record>path=/</txt-record> <txt-record>protocol=https</txt-record> <txt-record>description=PiKVM Web Server</txt-record> + <txt-record>model=$PIKVM_MODEL</txt-record> + <txt-record>video=$PIKVM_VIDEO</txt-record> + <txt-record>board=$PIKVM_BOARD</txt-record> + <txt-record>base=$_base</txt-record> <txt-record>serial=$_serial</txt-record> - <txt-record>model=$_model</txt-record> + <txt-record>model=$_platform</txt-record> </service> </service-group> end_of_file |