[network] Add "custom_net_ifaces" preseed

Allows users to specify a custom "/etc/network/interfaces" file.
Filename is not important, it will be copied as "interfaces" anyway!
parent a9c6b7b8
......@@ -19,6 +19,18 @@ class Install(module.Install):
shutil.copy2("/etc/resolv.conf", os.path.join(self.moduleclass.main_settings["target"], "etc/resolv.conf"))
def copy_interfaces(self):
""" Copies file specified in "custom_net_ifaces" preseed
to /etc/network on the target file system root.
MUST BE CALLED AFTER CLOSING THE CHROOT!
"""
custom_ifaces_file = self.moduleclass.settings["custom_net_ifaces"]
if custom_ifaces_file:
if os.path.isfile(custom_ifaces_file):
shutil.copy2(custom_ifaces_file, os.path.join(self.moduleclass.main_settings["target"], "etc/network/interfaces"))
else:
m.verbose("ERROR: File specified in \"custom_net_ifaces\" is not a regular file or doesn't exist!")
def configure(self):
""" Configures network. """
......@@ -54,4 +66,10 @@ class Module(module.Module):
self.install.close()
# Copy resolv.conf
self.install.copy_resolvconf()
self.install.copy_interfaces()
def seedpre(self):
"""
Caches settings.
"""
self.cache("custom_net_ifaces", None)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment