* Use openresolv to set the static nameserver configuration. Next

step is to get the DHCP client, OpenVPN etc. to use openresolv as
  well.

svn path=/nixos/trunk/; revision=32411
This commit is contained in:
Eelco Dolstra 2012-02-20 00:00:50 +00:00
parent 1707d1130f
commit a218a602d4
2 changed files with 12 additions and 10 deletions

View File

@ -96,6 +96,7 @@ mkdir -m 0755 -p /etc/nixos
# Miscellaneous boot time cleanup. # Miscellaneous boot time cleanup.
rm -rf /var/run /var/lock /var/log/upstart rm -rf /var/run /var/lock /var/log/upstart
rm -f /etc/resolv.conf
#echo -n "cleaning \`/tmp'..." #echo -n "cleaning \`/tmp'..."
#rm -rf --one-file-system /tmp/* #rm -rf --one-file-system /tmp/*

View File

@ -179,6 +179,7 @@ in
pkgs.nettools pkgs.nettools
pkgs.wirelesstools pkgs.wirelesstools
pkgs.rfkill pkgs.rfkill
pkgs.openresolv
] ]
++ optional (cfg.bridges != {}) pkgs.bridge_utils ++ optional (cfg.bridges != {}) pkgs.bridge_utils
++ optional cfg.enableIPv6 pkgs.ndisc6; ++ optional cfg.enableIPv6 pkgs.ndisc6;
@ -196,6 +197,7 @@ in
'' ''
set +e # continue in case of errors set +e # continue in case of errors
# Set MAC addresses of interfaces, if desired.
${flip concatMapStrings cfg.interfaces (i: ${flip concatMapStrings cfg.interfaces (i:
optionalString (i.macAddress != "") optionalString (i.macAddress != "")
'' ''
@ -236,16 +238,15 @@ in
'') '')
} }
# Set the nameservers. # Set the static DNS configuration, if given.
if test -n "${toString cfg.nameservers}"; then cat | ${pkgs.openresolv}/sbin/resolvconf -a static <<EOF
rm -f /etc/resolv.conf ${optionalString (cfg.nameservers != [] && cfg.domain != "") ''
if test -n "${cfg.domain}"; then domain ${cfg.domain}
echo "domain ${cfg.domain}" >> /etc/resolv.conf ''}
fi ${flip concatMapStrings cfg.nameservers (ns: ''
for i in ${toString cfg.nameservers}; do nameserver ${ns}
echo "nameserver $i" >> /etc/resolv.conf '')}
done EOF
fi
# Set the default gateway. # Set the default gateway.
${optionalString (cfg.defaultGateway != "") '' ${optionalString (cfg.defaultGateway != "") ''