1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-25 07:00:43 +00:00

* Option `networking.localCommands' to specify shell commands to be

executed after the network interfaces have been initialised.

svn path=/nixos/trunk/; revision=8752
This commit is contained in:
Eelco Dolstra 2007-05-24 14:50:17 +00:00
parent 4f5de40814
commit aab8fda25a
4 changed files with 24 additions and 5 deletions

View file

@ -23,5 +23,5 @@ substituteAll {
udev
upstart
];
bootLocal = writeText "boot.local" bootLocal;
bootLocal = writeText "local-cmds" bootLocal;
}

View file

@ -257,6 +257,19 @@
}
{
name = ["networking" "localCommands"];
default = "";
example = "text=anything; echo You can put $text here.";
description = "
Shell commands to be executed at the end of the
<literal>network-interfaces</literal> Upstart job. Note that if
you are using DHCP to obtain the network configuration,
interfaces may not be fully configured yet.
";
}
{
name = ["fileSystems"];
default = [];

View file

@ -67,10 +67,11 @@ import ../upstart-jobs/gather.nix {
# Network interfaces.
(import ../upstart-jobs/network-interfaces.nix {
inherit modprobe;
inherit (pkgs) nettools wirelesstools;
inherit (pkgs) nettools wirelesstools bash writeText;
nameservers = config.get ["networking" "nameservers"];
defaultGateway = config.get ["networking" "defaultGateway"];
interfaces = config.get ["networking" "interfaces"];
localCommands = config.get ["networking" "localCommands"];
})
# Nix daemon - required for multi-user Nix.

View file

@ -1,5 +1,6 @@
{ nettools, modprobe, wirelesstools
{ nettools, modprobe, wirelesstools, bash, writeText
, nameservers, defaultGateway, interfaces
, localCommands
}:
let
@ -21,7 +22,8 @@ start on hardware-scan
stop on shutdown
start script
${modprobe}/sbin/modprobe af_packet || true
export PATH=${modprobe}/sbin:$PATH
modprobe af_packet || true
for i in $(cd /sys/class/net && ls -d *); do
echo \"Bringing up network device $i...\"
@ -43,7 +45,7 @@ start script
wepKey=\${wepKeys[$n]}
# Set wireless networking stuff.
if test \"$essid\" != dhcp; then
if test \"$essid\" != default; then
${wirelesstools}/sbin/iwconfig \"$name\" essid \"$essid\" || true
fi
@ -76,6 +78,9 @@ start script
${nettools}/sbin/route add default gw \"${defaultGateway}\" || true
fi
# Run any user-specified commands.
${bash}/bin/sh ${writeText "local-net-cmds" localCommands} || true
end script
# Hack: Upstart doesn't yet support what we want: a service that