[master] [PATCH] Set the local hostname during installation

Vratislav Podzimek vpodzime at redhat.com
Tue Jan 8 12:49:27 UTC 2013


This allows post install commands to use the hostname of the installed
system.

Thanks to Stef Walter <stefw at redhat.com> for the original patch.

Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 pyanaconda/network.py | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index 2bf7832..0071794 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -738,15 +738,6 @@ def ifaceForHostIP(host):
 
     return routeInfo[routeInfo.index("dev") + 1]
 
-def setHostname(hn):
-    if flags.imageInstall:
-        log.info("image install -- not setting hostname")
-        return
-
-    log.info("setting installation environment hostname to %s" % hn)
-    iutil.execWithRedirect("hostname", ["-v", hn ],
-                           stdout="/dev/tty5", stderr="/dev/tty5")
-
 def copyFileToPath(file, destPath='', overwrite=False):
     if not os.path.isfile(file):
         return False
@@ -811,6 +802,15 @@ def get_ifcfg_value(iface, key, root_path=""):
     dev.loadIfcfgFile()
     return dev.get(key)
 
+def set_hostname(hn):
+    if flags.imageInstall:
+        log.info("image install -- not setting hostname")
+        return
+
+    log.info("setting installation environment hostname to %s" % hn)
+    iutil.execWithRedirect("hostname", ["-v", hn ],
+                           stdout="/dev/tty5", stderr="/dev/tty5")
+
 def write_hostname(rootpath, ksdata, overwrite=False):
     cfgfile = os.path.normpath(rootpath + hostnameFile)
     if (os.path.isfile(cfgfile) and not overwrite):
@@ -926,6 +926,7 @@ def usedByRootOnISCSI(iface, storage):
 
 def write_network_config(storage, ksdata, instClass, rootpath):
     write_hostname(rootpath, ksdata, overwrite=flags.livecdInstall)
+    set_hostname(ksdata.network.hostname)
     write_sysconfig_network(rootpath, ksdata, overwrite=flags.livecdInstall)
     disableIPV6(rootpath)
     if not flags.imageInstall:
-- 
1.7.11.7



More information about the anaconda-patches mailing list