diff options
| author | Franz Pletz <fpletz@fnordicwalking.de> | 2020-02-08 14:55:29 +0100 |
|---|---|---|
| committer | Franz Pletz <fpletz@fnordicwalking.de> | 2020-02-08 16:53:34 +0100 |
| commit | 7e62601adf8ca1a2d1556dbced7e3cc028af4029 (patch) | |
| tree | e644d20d0891f26823b6aa30573f7fe8a89fc83e | |
| parent | nixos/initrd-network: use ipconfig from klibc (diff) | |
| download | nixpkgs-origin/fix-predictable-ifnames-in-initrd-19.09.tar.gz | |
nixos/initrd-network: always run postCommandsorigin/fix-predictable-ifnames-in-initrd-19.09
As outlined in #71447, postCommands should always be run if networking
in initrd is enabled. regardless if the configuration actually
succeeded.
(cherry picked from commit 589789997fe882668eae25f1f0578230d8576506)
| -rw-r--r-- | nixos/modules/system/boot/initrd-network.nix | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/nixos/modules/system/boot/initrd-network.nix b/nixos/modules/system/boot/initrd-network.nix index d36850c2a16f..0ab6e626b340 100644 --- a/nixos/modules/system/boot/initrd-network.nix +++ b/nixos/modules/system/boot/initrd-network.nix @@ -113,8 +113,7 @@ in for o in $(cat /proc/cmdline); do case $o in ip=*) - ipconfig $o && hasNetwork=1 \ - && ifaces="$ifaces $(echo $o | cut -d: -f6)" + ipconfig $o && ifaces="$ifaces $(echo $o | cut -d: -f6)" ;; esac done @@ -122,28 +121,20 @@ in # Otherwise, use DHCP. + optionalString doDhcp '' - if [ -z "$hasNetwork" ]; then - - # Bring up all interfaces. - for iface in ${dhcpIfShellExpr}; do - echo "bringing up network interface $iface..." - ip link set "$iface" up && ifaces="$ifaces $iface" - done + # Bring up all interfaces. + for iface in ${dhcpIfShellExpr}; do + echo "bringing up network interface $iface..." + ip link set "$iface" up && ifaces="$ifaces $iface" + done - # Acquire DHCP leases. - for iface in ${dhcpIfShellExpr}; do - echo "acquiring IP address via DHCP on $iface..." - udhcpc --quit --now -i $iface -O staticroutes --script ${udhcpcScript} ${udhcpcArgs} && hasNetwork=1 - done - fi + # Acquire DHCP leases. + for iface in ${dhcpIfShellExpr}; do + echo "acquiring IP address via DHCP on $iface..." + udhcpc --quit --now -i $iface -O staticroutes --script ${udhcpcScript} ${udhcpcArgs} + done '' - + '' - if [ -n "$hasNetwork" ]; then - echo "networking is up!" - ${cfg.postCommands} - fi - ''); + + cfg.postCommands); boot.initrd.postMountCommands = mkIf cfg.flushBeforeStage2 '' for iface in $ifaces; do |
