mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-12 08:45:38 +02:00
fix: Move more directories
This commit is contained in:
24
cloud/packages/maitred/internal/system/id.go
Normal file
24
cloud/packages/maitred/internal/system/id.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
dbusPath = "/var/lib/dbus/machine-id"
|
||||
dbusPathEtc = "/etc/machine-id"
|
||||
)
|
||||
|
||||
// GetID returns the machine ID specified at `/var/lib/dbus/machine-id` or `/etc/machine-id`.
|
||||
// If there is an error reading the files an empty string is returned.
|
||||
func GetID() (string, error) {
|
||||
id, err := os.ReadFile(dbusPath)
|
||||
if err != nil {
|
||||
id, err = os.ReadFile(dbusPathEtc)
|
||||
}
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return strings.Trim(string(id), " \n"), nil
|
||||
}
|
||||
Reference in New Issue
Block a user