1
0
mirror of https://github.com/rancher/os.git synced 2025-06-27 23:36:49 +00:00
os/cmd/cloudinit/hostname/hostname.go
2015-04-21 19:06:40 -07:00

14 lines
243 B
Go

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)
}