kexec-installer: fixes for restoreNetwork

This commit is contained in:
lassulus 2022-11-25 11:37:50 +00:00
parent 3928958de5
commit 94384afdb6
2 changed files with 7 additions and 3 deletions

View file

@ -1,6 +1,6 @@
{ config, lib, modulesPath, pkgs, ... }: { config, lib, modulesPath, pkgs, ... }:
let let
restoreNetwork = pkgs.writers.writePython3Bin "restore-network" { restoreNetwork = pkgs.writers.writePython3 "restore-network" {
flakeIgnore = ["E501"]; flakeIgnore = ["E501"];
} ./restore_routes.py; } ./restore_routes.py;
in { in {
@ -35,7 +35,7 @@ in {
done done
# save the networking config for later use # save the networking config for later use
if ! type -p ip &>/dev/null; then if type -p ip &>/dev/null; then
ip --json addr > addrs.json ip --json addr > addrs.json
ip --json route > routes.json ip --json route > routes.json
else else
@ -95,7 +95,7 @@ in {
pkgs.iproute2 pkgs.iproute2
]; ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "network.target" ]; after = [ "network-online.target" ];
serviceConfig.ExecStart = "${restoreNetwork} /root/network/addrs.json /root/network/routes.json"; serviceConfig.ExecStart = "${restoreNetwork} /root/network/addrs.json /root/network/routes.json";
unitConfig.ConditionPathExists = [ unitConfig.ConditionPathExists = [

View file

@ -70,6 +70,8 @@ def main() -> None:
route["gateway"], route["gateway"],
"dev", "dev",
current_interface["ifname"], current_interface["ifname"],
"preference",
"1",
], ],
check=True check=True
) )
@ -82,6 +84,8 @@ def main() -> None:
route["dst"], route["dst"],
"dev", "dev",
current_interface["ifname"], current_interface["ifname"],
"preference",
"1",
], ],
check=True check=True
) )