* Don't start dhclient on interfaces that are explicitly configured.

svn path=/nixos/trunk/; revision=8014
This commit is contained in:
Eelco Dolstra 2007-02-22 14:26:53 +00:00
parent e23de214ab
commit ed36857d5e
2 changed files with 12 additions and 3 deletions

View file

@ -93,7 +93,8 @@ import ../upstart-jobs/gather.nix {
# DHCP client.
++ optional ["networking" "useDHCP"]
(import ../upstart-jobs/dhclient.nix {
inherit (pkgs) nettools dhcp;
inherit (pkgs) nettools dhcp lib;
interfaces = config.get ["networking" "interfaces"];
})
# SSH daemon.

View file

@ -1,4 +1,12 @@
{dhcp, nettools}:
{dhcp, nettools, interfaces, lib}:
let
# Don't start dhclient on explicitly configured interfaces.
ignoredInterfaces = ["lo"] ++
map (i: i.name) (lib.filter (i: i ? ipAddress) interfaces);
in
{
name = "dhclient";
@ -18,7 +26,7 @@ script
interfaces=
for i in $(cd /sys/class/net && ls -d *); do
if test \"$i\" != \"lo\"; then
if ! for j in ${toString ignoredInterfaces}; do echo $j; done | grep -F -x -q \"$i\"; then
echo \"Running dhclient on $i\"
interfaces=\"$interfaces $i\"
fi