fix: always update hostname for rhel-like os (#23016)

Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
Jian Qiu
2025-08-06 01:08:04 +08:00
committed by GitHub
co-authored by Qiu Jian
parent c0562f2573
commit 87dfcf7c84
+3 -3
View File
@@ -1316,10 +1316,10 @@ func (r *sRedhatLikeRootFs) DeployHostname(rootFs IDiskPartition, hn, domain str
centosHn += "NETWORKING=yes\n"
centosHn += fmt.Sprintf("HOSTNAME=%s\n", getHostname(hn, domain))
if err := rootFs.FilePutContents(sPath, centosHn, false, false); err != nil {
return err
return errors.Wrapf(err, "DeployHostname %s", sPath)
}
if rootFs.Exists("/etc/hostname", false) {
return rootFs.FilePutContents("/etc/hostname", hn, false, false)
if err := rootFs.FilePutContents("/etc/hostname", hn, false, false); err != nil {
return errors.Wrapf(err, "DeployHostname %s", "/etc/hostname")
}
return nil
}