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:
13
cmd/cloudinit/hostname/hostname.go
Normal file
13
cmd/cloudinit/hostname/hostname.go
Normal 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)
|
||||
}
|
Reference in New Issue
Block a user