* Start dhclient as an Upstart job.
svn path=/nixu/trunk/; revision=7078
This commit is contained in:
parent
70aca5974c
commit
369b48eadf
@ -86,6 +86,11 @@ rec {
|
|||||||
(import ./upstart-jobs/syslogd.nix {
|
(import ./upstart-jobs/syslogd.nix {
|
||||||
inherit (pkgs) sysklogd;
|
inherit (pkgs) sysklogd;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# DHCP client.
|
||||||
|
(import ./upstart-jobs/dhclient.nix {
|
||||||
|
dhcp = pkgs.dhcpWrapper;
|
||||||
|
})
|
||||||
]
|
]
|
||||||
|
|
||||||
# The terminals on ttyX.
|
# The terminals on ttyX.
|
||||||
@ -115,7 +120,6 @@ rec {
|
|||||||
nettools upstart;
|
nettools upstart;
|
||||||
inherit upstartJobs;
|
inherit upstartJobs;
|
||||||
shell = pkgs.bash + "/bin/sh";
|
shell = pkgs.bash + "/bin/sh";
|
||||||
dhcp = pkgs.dhcpWrapper;
|
|
||||||
|
|
||||||
# Additional stuff; add whatever you want here.
|
# Additional stuff; add whatever you want here.
|
||||||
path = [
|
path = [
|
||||||
|
@ -86,12 +86,7 @@ done
|
|||||||
modprobe af_packet
|
modprobe af_packet
|
||||||
for i in $(cd /sys/class/net && ls -d *); do
|
for i in $(cd /sys/class/net && ls -d *); do
|
||||||
echo "Bringing up network device $i..."
|
echo "Bringing up network device $i..."
|
||||||
if ifconfig $i up; then
|
ifconfig $i up
|
||||||
if test "$i" != "lo"; then
|
|
||||||
mkdir -p /var/state/dhcp
|
|
||||||
dhclient $i
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{ genericSubstituter, shell, coreutils, findutils
|
{ genericSubstituter, shell, coreutils, findutils
|
||||||
, utillinux, kernel, udev
|
, utillinux, kernel, udev
|
||||||
, module_init_tools, nettools, dhcp, upstart
|
, module_init_tools, nettools, upstart
|
||||||
, path ? []
|
, path ? []
|
||||||
|
|
||||||
, # Whether the root device is root only. If so, we'll mount a
|
, # Whether the root device is root only. If so, we'll mount a
|
||||||
@ -22,7 +22,6 @@ genericSubstituter {
|
|||||||
udev
|
udev
|
||||||
module_init_tools
|
module_init_tools
|
||||||
nettools
|
nettools
|
||||||
dhcp
|
|
||||||
upstart
|
upstart
|
||||||
];
|
];
|
||||||
extraPath = path;
|
extraPath = path;
|
||||||
|
29
test/upstart-jobs/dhclient.nix
Normal file
29
test/upstart-jobs/dhclient.nix
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{dhcp}:
|
||||||
|
|
||||||
|
{
|
||||||
|
name = "dhclient";
|
||||||
|
|
||||||
|
job = "
|
||||||
|
description \"DHCP client\"
|
||||||
|
|
||||||
|
start on startup
|
||||||
|
stop on shutdown
|
||||||
|
|
||||||
|
script
|
||||||
|
interfaces=
|
||||||
|
for i in $(cd /sys/class/net && ls -d *); do
|
||||||
|
if test \"$i\" != \"lo\" -a \"$(cat /sys/class/net/$i/operstate)\" != 'down'; then
|
||||||
|
interfaces=\"$interfaces $i\"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if test -z \"$interfaces\"; then
|
||||||
|
echo 'No interfaces on which to start dhclient!'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec ${dhcp}/sbin/dhclient -d $interfaces
|
||||||
|
end script
|
||||||
|
";
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user