mirror of
https://github.com/rancher/os.git
synced 2025-06-28 15:56:58 +00:00
14 lines
243 B
Go
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)
|
||
|
}
|