From 07d70a0a916b3c7ede34671603c1e964a1c7bf30 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 11 Nov 2020 19:11:22 +0000 Subject: Added a simple INI handler, and a helper function under Installer().configure_nic() to help with nic configuration. Supports a crude DHCP configuration and a minimal static IP handler. --- archinstall/lib/installer.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 775de50a..c233a876 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -6,6 +6,7 @@ from .general import * from .user_interaction import * from .profiles import Profile from .mirrors import * +from .systemd import Networkd from .output import log, LOG_LEVELS from .storage import storage @@ -149,6 +150,24 @@ class Installer(): def arch_chroot(self, cmd, *args, **kwargs): return self.run_command(cmd) + def configure_nic(self, nic, dhcp=True, ip=None, gateway=None, dns=None, *args, **kwargs): + if dhcp: + conf = Networkd(Match={"Name": nic}, Network={"DHCP": "yes"}) + else: + assert ip + + network = {"Address": ip} + if gateway: + network["Gateway"] = gateway + if dns: + assert type(dns) == list + network["DNS"] = dns + + conf = Networkd(Match={"Name": nic}, Network=network) + + with open(f"{self.mountpoint}/etc/systemd/network/10-{nic}.network", "a") as netconf: + netconf.write(str(conf)) + def minimal_installation(self): ## Add nessecary packages if encrypting the drive ## (encrypted partitions default to btrfs for now, so we need btrfs-progs) -- cgit v1.2.3-54-g00ecf