initrd-network: call postCommands only if network is up

+9 -4
+9 -4
nixos/modules/system/boot/initrd-network.nix
··· 63 copy_bin_and_libs ${pkgs.mkinitcpio-nfs-utils}/bin/ipconfig 64 ''; 65 66 - boot.initrd.preLVMCommands = 67 # Search for interface definitions in command line. 68 - mkBefore '' 69 for o in $(cat /proc/cmdline); do 70 case $o in 71 ip=*) ··· 87 88 # Acquire a DHCP lease. 89 echo "acquiring IP address via DHCP..." 90 - udhcpc --quit --now --script ${udhcpcScript} 91 fi 92 '' 93 94 - + cfg.postCommands; 95 96 }; 97
··· 63 copy_bin_and_libs ${pkgs.mkinitcpio-nfs-utils}/bin/ipconfig 64 ''; 65 66 + boot.initrd.preLVMCommands = mkBefore ( 67 # Search for interface definitions in command line. 68 + '' 69 for o in $(cat /proc/cmdline); do 70 case $o in 71 ip=*) ··· 87 88 # Acquire a DHCP lease. 89 echo "acquiring IP address via DHCP..." 90 + udhcpc --quit --now --script ${udhcpcScript} && hasNetwork=1 91 fi 92 '' 93 94 + + '' 95 + if [ -n "$hasNetwork" ]; then 96 + echo "networking is up!" 97 + ${cfg.postCommands} 98 + fi 99 + ''); 100 101 }; 102