* Set some wireless settings (ESSID, WEP key).
svn path=/nixos/trunk/; revision=8163
This commit is contained in:
parent
2bff886ae1
commit
90f1dbe548
@ -60,7 +60,7 @@ import ../upstart-jobs/gather.nix {
|
|||||||
|
|
||||||
# Network interfaces.
|
# Network interfaces.
|
||||||
(import ../upstart-jobs/network-interfaces.nix {
|
(import ../upstart-jobs/network-interfaces.nix {
|
||||||
inherit (pkgs) nettools kernel module_init_tools;
|
inherit (pkgs) nettools kernel module_init_tools wirelesstools;
|
||||||
nameservers = config.get ["networking" "nameservers"];
|
nameservers = config.get ["networking" "nameservers"];
|
||||||
defaultGateway = config.get ["networking" "defaultGateway"];
|
defaultGateway = config.get ["networking" "defaultGateway"];
|
||||||
interfaces = config.get ["networking" "interfaces"];
|
interfaces = config.get ["networking" "interfaces"];
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# !!! Don't like it that I have to pass the kernel here.
|
# !!! Don't like it that I have to pass the kernel here.
|
||||||
{ nettools, kernel, module_init_tools
|
{ nettools, kernel, module_init_tools, wirelesstools
|
||||||
, nameservers, defaultGateway, interfaces
|
, nameservers, defaultGateway, interfaces
|
||||||
}:
|
}:
|
||||||
|
|
||||||
@ -7,8 +7,10 @@ let
|
|||||||
|
|
||||||
# !!! use XML
|
# !!! use XML
|
||||||
names = map (i: i.name) interfaces;
|
names = map (i: i.name) interfaces;
|
||||||
ipAddresses = map (i: i.ipAddress) interfaces;
|
ipAddresses = map (i: if i ? ipAddress then i.ipAddress else "dhcp") interfaces;
|
||||||
subnetMasks = map (i: if i ? subnetMask then i.subnetMask else "default") interfaces;
|
subnetMasks = map (i: if i ? subnetMask then i.subnetMask else "default") interfaces;
|
||||||
|
essids = map (i: if i ? essid then i.essid else "default") interfaces;
|
||||||
|
wepKeys = map (i: if i ? wepKey then i.wepKey else "nokey") interfaces;
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
@ -33,17 +35,35 @@ start script
|
|||||||
names=(${toString names})
|
names=(${toString names})
|
||||||
ipAddresses=(${toString ipAddresses})
|
ipAddresses=(${toString ipAddresses})
|
||||||
subnetMasks=(${toString subnetMasks})
|
subnetMasks=(${toString subnetMasks})
|
||||||
|
essids=(${toString essids})
|
||||||
|
wepKeys=(${toString wepKeys})
|
||||||
|
|
||||||
for ((n = 0; n < \${#names[*]}; n++)); do
|
for ((n = 0; n < \${#names[*]}; n++)); do
|
||||||
name=\${names[$n]}
|
name=\${names[$n]}
|
||||||
ipAddress=\${ipAddresses[$n]}
|
ipAddress=\${ipAddresses[$n]}
|
||||||
subnetMask=\${subnetMasks[$n]}
|
subnetMask=\${subnetMasks[$n]}
|
||||||
echo \"Configuring interface $name...\"
|
essid=\${essids[$n]}
|
||||||
extraFlags=
|
wepKey=\${wepKeys[$n]}
|
||||||
if test \"$subnetMask\" != default; then
|
|
||||||
extraFlags=\"$extraFlags netmask $subnetMask\"
|
# Set wireless networking stuff.
|
||||||
|
if test \"$essid\" != dhcp; then
|
||||||
|
${wirelesstools}/sbin/iwconfig \"$name\" essid \"$essid\"
|
||||||
fi
|
fi
|
||||||
${nettools}/sbin/ifconfig \"$name\" \"$ipAddress\" $extraFlags || true
|
|
||||||
|
if test \"$wepKey\" != nokey; then
|
||||||
|
${wirelesstools}/sbin/iwconfig \"$name\" key \"$(cat \"$wepKey\")\"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set IP address / netmask.
|
||||||
|
if test \"$ipAddress\" != dhcp; then
|
||||||
|
echo \"Configuring interface $name...\"
|
||||||
|
extraFlags=
|
||||||
|
if test \"$subnetMask\" != default; then
|
||||||
|
extraFlags=\"$extraFlags netmask $subnetMask\"
|
||||||
|
fi
|
||||||
|
${nettools}/sbin/ifconfig \"$name\" \"$ipAddress\" $extraFlags || true
|
||||||
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Set the nameservers.
|
# Set the nameservers.
|
||||||
|
Loading…
Reference in New Issue
Block a user