hostinfo: look up Synology hardware a more specific way

Fixes #2991

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/2997/head
Brad Fitzpatrick 3 years ago committed by Brad Fitzpatrick
parent a71fb6428d
commit 58e1475ec7

@ -22,13 +22,30 @@ import (
func init() { func init() {
osVersion = osVersionLinux osVersion = osVersionLinux
if v, _ := os.ReadFile("/sys/firmware/devicetree/base/model"); len(v) > 0 { if v := linuxDeviceModel(); v != "" {
// Look up "Raspberry Pi 4 Model B Rev 1.2", SetDeviceModel(v)
// etc. Usually set on ARM SBCs.
SetDeviceModel(strings.Trim(string(v), "\x00\r\n\t "))
} }
} }
func linuxDeviceModel() string {
for _, path := range []string{
// First try the Synology-specific location.
// Example: "DS916+-j"
"/proc/sys/kernel/syno_hw_version",
// Otherwise, try the Devicetree model, usually set on
// ARM SBCs, etc.
// Example: "Raspberry Pi 4 Model B Rev 1.2"
"/sys/firmware/devicetree/base/model", // Raspberry Pi 4 Model B Rev 1.2"
} {
b, _ := os.ReadFile(path)
if s := strings.Trim(string(b), "\x00\r\n\t "); s != "" {
return s
}
}
return ""
}
func osVersionLinux() string { func osVersionLinux() string {
dist := distro.Get() dist := distro.Get()
propFile := "/etc/os-release" propFile := "/etc/os-release"

Loading…
Cancel
Save