1
0
mirror of https://github.com/rancher/os.git synced 2025-09-01 14:48:55 +00:00

set hostname from cloud-init

This commit is contained in:
wlan0
2015-03-25 15:27:33 -07:00
committed by Darren Shepherd
parent b339252a6f
commit 505174db35
3 changed files with 44 additions and 3 deletions

View File

@@ -0,0 +1,13 @@
package hostname
import (
"io/ioutil"
"syscall"
)
func SetHostname(hostname string) error {
if err := syscall.Sethostname([]byte(hostname)); err != nil {
return err
}
return ioutil.WriteFile("/etc/hostname", []byte(hostname), 0644)
}