diff --git a/nix/kexec-installer/module.nix b/nix/kexec-installer/module.nix index 3f737b6..c9e7f28 100644 --- a/nix/kexec-installer/module.nix +++ b/nix/kexec-installer/module.nix @@ -36,10 +36,9 @@ in { # save the networking config for later use if type -p ip &>/dev/null; then - ip -4 --json addr > addrs-v4.json - ip -4 --json addr > addrs-v6.json + ip --json addr > addrs.json - ip -6 --json route > routes-v4.json + ip -4 --json route > routes-v4.json ip -6 --json route > routes-v6.json else echo "Skip saving static network addresses because no iproute2 binary is available." 2>&1 @@ -100,12 +99,11 @@ in { wantedBy = [ "multi-user.target" ]; serviceConfig.ExecStart = [ - "${restoreNetwork} /root/network/addrs-v4.json /root/network/addrs-v6.json /root/network/routes-v4.json /root/network/routes-v6.json" + "${restoreNetwork} /root/network/addrs.json /root/network/routes-v4.json /root/network/routes-v6.json" ]; unitConfig.ConditionPathExists = [ - "/root/network/addrs-v4.json" - "/root/network/addrs-v6.json" + "/root/network/addrs.json" "/root/network/routes-v4.json" "/root/network/routes-v6.json" ]; diff --git a/nix/kexec-installer/restore_routes.py b/nix/kexec-installer/restore_routes.py index 9eb1f0a..152ccbe 100644 --- a/nix/kexec-installer/restore_routes.py +++ b/nix/kexec-installer/restore_routes.py @@ -85,28 +85,25 @@ IPv6AcceptRA = yes def main() -> None: - if len(sys.argv) < 5: + if len(sys.argv) < 4: print( - f"USAGE: {sys.argv[0]} addresses-v4 addresses-v6 routes-v4 routes-v6 [networkd-directory]", + f"USAGE: {sys.argv[0]} addresses routes-v4 routes-v6 [networkd-directory]", file=sys.stderr, ) sys.exit(1) with open(sys.argv[1]) as f: - v4_addresses = json.load(f) + addresses = json.load(f) with open(sys.argv[2]) as f: - v6_addresses = json.load(f) - with open(sys.argv[3]) as f: v4_routes = json.load(f) - with open(sys.argv[4]) as f: + with open(sys.argv[3]) as f: v6_routes = json.load(f) - if len(sys.argv) >= 5: - networkd_directory = Path(sys.argv[5]) + if len(sys.argv) >= 4: + networkd_directory = Path(sys.argv[4]) else: networkd_directory = Path("/etc/systemd/network") - addresses = v4_addresses + v6_addresses relevant_interfaces = filter_interfaces(addresses) relevant_routes = filter_routes(v4_routes) + filter_routes(v6_routes)