mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-08 20:30:18 +00:00
Merge pull request #1917 from balena-os/compulab-no-dmidecode
Add system id/model support for Compulab IOT-gate
This commit is contained in:
commit
790259560a
@ -3,6 +3,10 @@ import * as _ from 'lodash';
|
|||||||
import * as memoizee from 'memoizee';
|
import * as memoizee from 'memoizee';
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
|
|
||||||
|
// TODO: remove this once we can update Node to v16 and typescript
|
||||||
|
// to an es2021 compatible version for native Promise.any
|
||||||
|
import { Promise } from 'bluebird';
|
||||||
|
|
||||||
import { exec } from './fs-utils';
|
import { exec } from './fs-utils';
|
||||||
|
|
||||||
export async function getCpuUsage(): Promise<number> {
|
export async function getCpuUsage(): Promise<number> {
|
||||||
@ -71,7 +75,10 @@ export async function getCpuTemp(): Promise<number> {
|
|||||||
export async function getSystemId(): Promise<string | undefined> {
|
export async function getSystemId(): Promise<string | undefined> {
|
||||||
try {
|
try {
|
||||||
// This will work on arm devices
|
// This will work on arm devices
|
||||||
const buffer = await fs.readFile('/proc/device-tree/serial-number');
|
const buffer = await Promise.any([
|
||||||
|
fs.readFile('/proc/device-tree/serial-number'),
|
||||||
|
fs.readFile('/proc/device-tree/product-sn'),
|
||||||
|
]);
|
||||||
// Remove the null byte at the end
|
// Remove the null byte at the end
|
||||||
return buffer.toString('utf-8').replace(/\0/g, '');
|
return buffer.toString('utf-8').replace(/\0/g, '');
|
||||||
} catch {
|
} catch {
|
||||||
@ -85,7 +92,10 @@ export async function getSystemId(): Promise<string | undefined> {
|
|||||||
|
|
||||||
export async function getSystemModel(): Promise<string | undefined> {
|
export async function getSystemModel(): Promise<string | undefined> {
|
||||||
try {
|
try {
|
||||||
const buffer = await fs.readFile('/proc/device-tree/model');
|
const buffer = await Promise.any([
|
||||||
|
fs.readFile('/proc/device-tree/model'),
|
||||||
|
fs.readFile('/proc/device-tree/product-name'),
|
||||||
|
]);
|
||||||
// Remove the null byte at the end
|
// Remove the null byte at the end
|
||||||
return buffer.toString('utf-8').replace(/\0/g, '');
|
return buffer.toString('utf-8').replace(/\0/g, '');
|
||||||
} catch {
|
} catch {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user