1
0
mirror of https://github.com/rancher/os.git synced 2025-06-28 15:56:58 +00:00
os/cmd/cloudinit/hostname/hostname.go

14 lines
243 B
Go
Raw Normal View History

2015-03-25 22:27:33 +00:00
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)
}