Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for AIX #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ All machine IDs are usually generated during system installation and stay consta

The following sources are used:

* **AIX** uses the OS (or WPAR if applicable) UUID from the `os_uuid` attribute
* **BSD** uses `/etc/hostid` and `smbios.system.uuid` as a fallback
* **Linux** uses `/var/lib/dbus/machine-id` ([man](http://man7.org/linux/man-pages/man5/machine-id.5.html))
* **OS X** uses `IOPlatformUUID`
Expand Down Expand Up @@ -141,6 +142,13 @@ hashedID, err := machineid.ProtectedID("myAppName")

Don't want to download code, and just need a way to get the data by yourself?


AIX:

```bash
lsattr -l sys0 -a os_uuid -E | cut -f 2 -d ' '
```

BSD:

```bash
Expand Down
20 changes: 20 additions & 0 deletions id_aix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// +build aix

package machineid

import (
"bytes"
"os"
"strings"
)

// machineID returns the operating system uuid set in the kernel or WPAR uuid if
// applicable.
func machineID() (string, error) {
buf := &bytes.Buffer{}
err := run(buf, os.Stderr, "lsattr", "-l", "sys0", "-a", "os_uuid","-E")
if err != nil {
return "", err
}
return strings.Split(buf.String()," ")[1], nil
}