patch from E Jaffe to fix eth0 config files with mac address (if specified)
[bootmanager.git] / source / steps / InstallWriteConfig.py
index d7fddcc..b9fd28f 100644 (file)
@@ -154,8 +154,12 @@ def Run( vars, log ):
     # boot cd.
     log.write( "Writing /etc/modprobe.conf\n" )
 
+    # get the kernel version
+    initrd= os.readlink( "%s/boot/initrd-boot" % SYSIMG_PATH )
+    kernel_version= initrd.replace("initrd-", "").replace(".img", "")
+
     sysinfo= systeminfo()
-    sysmods= sysinfo.get_system_modules(SYSIMG_PATH)
+    sysmods= sysinfo.get_system_modules(SYSIMG_PATH, kernel_version)
     if sysmods is None:
         raise BootManagerException, "Unable to get list of system modules."
         
@@ -256,11 +260,10 @@ def Run( vars, log ):
         rootdev= file( "%s/%s" % (SYSIMG_PATH,PARTITIONS["mapper-root"]), "w" )
         rootdev.close()
 
-    utils.sysexec( "chroot %s sh -c '" \
-                   "kernelversion=`ls /lib/modules | tail -1` && " \
-                   "rm -f /boot/initrd-$kernelversion.img && " \
-                   "mkinitrd /boot/initrd-$kernelversion.img $kernelversion'" % \
-                   SYSIMG_PATH, log )
+    # initrd set above
+    utils.removefile( "%s/boot/%s" % (SYSIMG_PATH, initrd) )
+    utils.sysexec( "chroot %s mkinitrd /boot/initrd-%s.img %s" % \
+                   (SYSIMG_PATH, kernel_version, kernel_version), log )
 
     if fake_root_lvm == 1:
         utils.removefile( "%s/%s" % (SYSIMG_PATH,PARTITIONS["mapper-root"]) )
@@ -356,6 +359,7 @@ def write_network_configuration( vars, log ):
         network= network_settings['network']
         netmask= network_settings['netmask']
         dns1= network_settings['dns1']
+        mac= network_settings['mac']
     except KeyError, e:
         raise BootManagerException, "Missing value %s in network settings." % str(e)
 
@@ -387,6 +391,8 @@ def write_network_configuration( vars, log ):
     else:
         eth0_file.write( "BOOTPROTO=dhcp\n" )
         eth0_file.write( "DHCP_HOSTNAME=%s\n" % hostname )
+    if mac != "":
+        eth0_file.write( "HWADDR=%s\n" % mac )
     eth0_file.write( "ONBOOT=yes\n" )
     eth0_file.write( "USERCTL=no\n" )
     eth0_file.close()