initrd-network: call postCommands only if network is up

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