* 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 {
|
||||
inherit (pkgs) sysklogd;
|
||||
})
|
||||
|
||||
# DHCP client.
|
||||
(import ./upstart-jobs/dhclient.nix {
|
||||
dhcp = pkgs.dhcpWrapper;
|
||||
})
|
||||
]
|
||||
|
||||
# The terminals on ttyX.
|
||||
|
@ -115,7 +120,6 @@ rec {
|
|||
nettools upstart;
|
||||
inherit upstartJobs;
|
||||
shell = pkgs.bash + "/bin/sh";
|
||||
dhcp = pkgs.dhcpWrapper;
|
||||
|
||||
# Additional stuff; add whatever you want here.
|
||||
path = [
|
||||
|
|
|
@ -86,12 +86,7 @@ done
|
|||
modprobe af_packet
|
||||
for i in $(cd /sys/class/net && ls -d *); do
|
||||
echo "Bringing up network device $i..."
|
||||
if ifconfig $i up; then
|
||||
if test "$i" != "lo"; then
|
||||
mkdir -p /var/state/dhcp
|
||||
dhclient $i
|
||||
fi
|
||||
fi
|
||||
ifconfig $i up
|
||||
done
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{ genericSubstituter, shell, coreutils, findutils
|
||||
, utillinux, kernel, udev
|
||||
, module_init_tools, nettools, dhcp, upstart
|
||||
, module_init_tools, nettools, upstart
|
||||
, path ? []
|
||||
|
||||
, # Whether the root device is root only. If so, we'll mount a
|
||||
|
@ -22,7 +22,6 @@ genericSubstituter {
|
|||
udev
|
||||
module_init_tools
|
||||
nettools
|
||||
dhcp
|
||||
upstart
|
||||
];
|
||||
extraPath = path;
|
||||
|
|
|
@ -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…
Reference in New Issue