feat(etcd): Default etcd name to /etc/machine-id

This commit is contained in:
Brian Waldon
2014-03-18 09:36:31 -07:00
parent 61ffbd41c9
commit f5765e4dde
5 changed files with 71 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ package system
import (
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
@@ -161,3 +162,8 @@ func ExecuteScript(scriptPath string) (string, error) {
func SetHostname(hostname string) error {
return exec.Command("hostnamectl", "set-hostname", hostname).Run()
}
func MachineID(root string) string {
contents, _ := ioutil.ReadFile(path.Join(root, "etc", "machine-id"))
return strings.TrimSpace(string(contents))
}