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

Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
Jian Qiu
2025-08-06 01:07:38 +08:00
committed by GitHub
co-authored by Qiu Jian
parent 1f39911996
commit 4d45708d11
+3 -3
View File
@@ -1295,10 +1295,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
}