From 962b1df3aa805fa02a9b0932e6d14778d04bb034 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 20 Nov 2006 17:06:44 +0000 Subject: [PATCH] * Some more upstartification. svn path=/nixu/trunk/; revision=7081 --- test/boot-environment.nix | 8 +++++- test/boot-stage-2-init.sh | 8 ------ test/boot-stage-2.nix | 3 +- test/upstart-jobs/dhclient.nix | 4 +-- test/upstart-jobs/network-interfaces.nix | 35 ++++++++++++++++++++++++ 5 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 test/upstart-jobs/network-interfaces.nix diff --git a/test/boot-environment.nix b/test/boot-environment.nix index a32ebd48c72..e0acb16252e 100644 --- a/test/boot-environment.nix +++ b/test/boot-environment.nix @@ -87,6 +87,11 @@ rec { inherit (pkgs) sysklogd; }) + # Network interfaces. + (import ./upstart-jobs/network-interfaces.nix { + inherit (pkgs) nettools kernel; + }) + # DHCP client. (import ./upstart-jobs/dhclient.nix { dhcp = pkgs.dhcpWrapper; @@ -117,7 +122,7 @@ rec { bootStage2 = import ./boot-stage-2.nix { inherit (pkgs) genericSubstituter coreutils findutils utillinux kernel udev module_init_tools - nettools upstart; + upstart; inherit upstartJobs; shell = pkgs.bash + "/bin/sh"; @@ -137,6 +142,7 @@ rec { pkgs.less pkgs.nano pkgs.netcat + pkgs.nettools pkgs.perl pkgs.procps pkgs.rsync diff --git a/test/boot-stage-2-init.sh b/test/boot-stage-2-init.sh index 96d92b1ba77..e624fdbacc1 100644 --- a/test/boot-stage-2-init.sh +++ b/test/boot-stage-2-init.sh @@ -82,14 +82,6 @@ for i in /sys/bus/pci/devices/*/modalias; do done -# Bring up the network devices. -modprobe af_packet -for i in $(cd /sys/class/net && ls -d *); do - echo "Bringing up network device $i..." - ifconfig $i up -done - - # login/su absolutely need this. test -e /etc/login.defs || touch /etc/login.defs diff --git a/test/boot-stage-2.nix b/test/boot-stage-2.nix index a7d22c3fb79..dc8cfbf891f 100644 --- a/test/boot-stage-2.nix +++ b/test/boot-stage-2.nix @@ -1,6 +1,6 @@ { genericSubstituter, shell, coreutils, findutils , utillinux, kernel, udev -, module_init_tools, nettools, upstart +, module_init_tools, upstart , path ? [] , # Whether the root device is root only. If so, we'll mount a @@ -21,7 +21,6 @@ genericSubstituter { utillinux udev module_init_tools - nettools upstart ]; extraPath = path; diff --git a/test/upstart-jobs/dhclient.nix b/test/upstart-jobs/dhclient.nix index 8a5c4fe9a5f..a9c9f375bbb 100644 --- a/test/upstart-jobs/dhclient.nix +++ b/test/upstart-jobs/dhclient.nix @@ -6,8 +6,8 @@ job = " description \"DHCP client\" -start on startup -stop on shutdown +start on network-interfaces +stop on network-interfaces/stop script interfaces= diff --git a/test/upstart-jobs/network-interfaces.nix b/test/upstart-jobs/network-interfaces.nix new file mode 100644 index 00000000000..3539a29afeb --- /dev/null +++ b/test/upstart-jobs/network-interfaces.nix @@ -0,0 +1,35 @@ +# !!! Don't like it that I have to pass the kernel here. +{nettools, kernel}: + +{ + name = "network-interfaces"; + + job = " +start on startup +stop on shutdown + +start script + export MODULE_DIR=${kernel}/lib/modules/ + + modprobe af_packet + + for i in $(cd /sys/class/net && ls -d *); do + echo \"Bringing up network device $i...\" + ${nettools}/sbin/ifconfig $i up || true + done +end script + +# Hack: Upstart doesn't yet support what we want: a service that +# doesn't have a running process associated with it. +respawn sleep 10000 + +stop script + for i in $(cd /sys/class/net && ls -d *); do + echo \"Bringing up network device $i...\" + ${nettools}/sbin/ifconfig $i down || true + done +end script + + "; + +}