[PATCH 1/3] Write /etc/hostname (#871543)
Radek Vykydal
rvykydal at redhat.com
Tue Dec 4 13:37:23 UTC 2012
Looks good to me.
On 12/04/2012 02:29 PM, Michal Schmidt wrote:
> Write the hostname to /etc/hostname instead of /etc/sysconfig/network.
> ---
> pyanaconda/network.py | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/pyanaconda/network.py b/pyanaconda/network.py
> index 1df8ab0..1b22966 100644
> --- a/pyanaconda/network.py
> +++ b/pyanaconda/network.py
> @@ -51,6 +51,7 @@ log = logging.getLogger("anaconda")
> sysconfigDir = "/etc/sysconfig"
> netscriptsDir = "%s/network-scripts" % (sysconfigDir)
> networkConfFile = "%s/network" % (sysconfigDir)
> +hostnameFile = "/etc/hostname"
> ipv6ConfFile = "/etc/modprobe.d/ipv6.conf"
> ifcfgLogFile = "/tmp/ifcfg.log"
> CONNECTION_TIMEOUT = 45
> @@ -798,6 +799,17 @@ def get_ifcfg_value(iface, key, root_path=""):
> dev.loadIfcfgFile()
> return dev.get(key)
>
> +def write_hostname(rootpath, ksdata, overwrite=False):
> + cfgfile = os.path.normpath(rootpath + hostnameFile)
> + if (os.path.isfile(cfgfile) and not overwrite):
> + return False
> +
> + f = open(cfgfile, "w")
> + f.write("%s\n" % ksdata.network.hostname)
> + f.close()
> +
> + return True
> +
> def write_sysconfig_network(rootpath, ksdata, overwrite=False):
>
> cfgfile = os.path.normpath(rootpath + networkConfFile)
> @@ -807,7 +819,6 @@ def write_sysconfig_network(rootpath, ksdata, overwrite=False):
> f = open(cfgfile, "w")
> f.write("# Generated by anaconda\n")
> f.write("NETWORKING=yes\n")
> - f.write("HOSTNAME=%s\n" % ksdata.network.hostname)
>
> gateway = ipv6_defaultgw = None
> for iface in reversed(getDevices()):
> @@ -902,6 +913,7 @@ def usedByRootOnISCSI(iface, storage):
> return False
>
> def writeNetworkConf(storage, ksdata, instClass):
> + write_hostname(ROOT_PATH, ksdata, overwrite=flags.livecdInstall)
> write_sysconfig_network(ROOT_PATH, ksdata, overwrite=flags.livecdInstall)
> disableIPV6(ROOT_PATH)
> if not flags.imageInstall:
More information about the anaconda-patches
mailing list