summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2011-05-27 21:31:10 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2011-05-27 21:31:10 +0200
commit02bca259924b70cf5371f57b75f9224dc7e55636 (patch)
tree306ef6572546481788e29e36834ce7774c57fc7c
parent1c808eeee8177044b5c4468c0b5c4532cc2133f0 (diff)
downloadptxdist-02bca259924b70cf5371f57b75f9224dc7e55636.tar.gz
ptxdist-02bca259924b70cf5371f57b75f9224dc7e55636.tar.xz
initmethod-systemd: add service for ifup/ifdown networking
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
-rwxr-xr-xgeneric/lib/systemd/ifupdown-prepare2
-rw-r--r--generic/lib/systemd/system/ifupdown-prepare.service11
-rw-r--r--generic/lib/systemd/system/ifupdown.service10
-rw-r--r--rules/initmethod-systemd.in16
-rw-r--r--rules/initmethod-systemd.make23
5 files changed, 62 insertions, 0 deletions
diff --git a/generic/lib/systemd/ifupdown-prepare b/generic/lib/systemd/ifupdown-prepare
new file mode 100755
index 000000000..6a622dc13
--- /dev/null
+++ b/generic/lib/systemd/ifupdown-prepare
@@ -0,0 +1,2 @@
+#!/bin/sh
+ifconfig | awk '/^[^ ]/ { printf "%s=kernel\n", $1 }' > /var/run/ifstate
diff --git a/generic/lib/systemd/system/ifupdown-prepare.service b/generic/lib/systemd/system/ifupdown-prepare.service
new file mode 100644
index 000000000..2c2c43b8f
--- /dev/null
+++ b/generic/lib/systemd/system/ifupdown-prepare.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Mark kernel activated network interfaces as up
+Before=ifupdown.service
+ConditionPathExists=!/var/run/ifstate
+#ConditionKernelCommandLine=nfsroot
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/lib/systemd/ifupdown-prepare
+
diff --git a/generic/lib/systemd/system/ifupdown.service b/generic/lib/systemd/system/ifupdown.service
new file mode 100644
index 000000000..f9dd5b473
--- /dev/null
+++ b/generic/lib/systemd/system/ifupdown.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Handle network interface with ifup/ifdown
+Before=network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/sbin/ifup -a
+ExecStop=/sbin/ifdown -a
+
diff --git a/rules/initmethod-systemd.in b/rules/initmethod-systemd.in
new file mode 100644
index 000000000..07010b4c9
--- /dev/null
+++ b/rules/initmethod-systemd.in
@@ -0,0 +1,16 @@
+## SECTION=initmethod
+
+if INITMETHOD_SYSTEMD
+
+config INITMETHOD_SYSTEMD_IFUPDOWN
+ bool
+ select BUSYBOX_IFUPDOWN if BUSYBOX
+ select BUSYBOX_IFCONFIG if BUSYBOX
+ select BUSYBOX_FEATURE_IFUPDOWN_IP if BUSYBOX
+ prompt "install simple network service"
+ help
+ Enable this to install services to handle networks with ifup/ifdown
+
+endif
+
+
diff --git a/rules/initmethod-systemd.make b/rules/initmethod-systemd.make
index a1354d51d..4a0667fce 100644
--- a/rules/initmethod-systemd.make
+++ b/rules/initmethod-systemd.make
@@ -30,6 +30,29 @@ $(STATEDIR)/initmethod-systemd.targetinstall:
@$(call install_alternative, initmethod-systemd, 0, 0, 0755, /lib/init/initmethod-bbinit-functions.sh)
+ifdef PTXCONF_INITMETHOD_SYSTEMD_IFUPDOWN
+ @$(call install_alternative, initmethod-systemd, 0, 0, 0755, \
+ /lib/systemd/ifupdown-prepare)
+ @$(call install_alternative, initmethod-systemd, 0, 0, 0644, \
+ /lib/systemd/system/ifupdown-prepare.service)
+ @$(call install_link, initmethod-systemd, ../ifupdown-prepare.service, \
+ /lib/systemd/system/ifupdown.service.wants/ifupdown-prepare.service)
+
+ @$(call install_alternative, initmethod-systemd, 0, 0, 0644, \
+ /lib/systemd/system/ifupdown.service)
+ @$(call install_link, initmethod-systemd, ../ifupdown.service, \
+ /lib/systemd/system/network.target.wants/ifupdown.service)
+
+ @$(call install_link, initmethod-systemd, ../network.target, \
+ /lib/systemd/system/multi-user.target.wants/network.target)
+
+ @$(call install_alternative, initmethod-systemd, 0, 0, 0644, /etc/network/interfaces)
+ @$(call install_copy, initmethod-systemd, 0, 0, 0755, /etc/network/if-down.d)
+ @$(call install_copy, initmethod-systemd, 0, 0, 0755, /etc/network/if-up.d)
+ @$(call install_copy, initmethod-systemd, 0, 0, 0755, /etc/network/if-post-down.d)
+ @$(call install_copy, initmethod-systemd, 0, 0, 0755, /etc/network/if-pre-up.d)
+endif
+
@$(call install_finish,initmethod-systemd)
@$(call touch)