From 02bca259924b70cf5371f57b75f9224dc7e55636 Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Fri, 27 May 2011 21:31:10 +0200 Subject: initmethod-systemd: add service for ifup/ifdown networking Signed-off-by: Michael Olbrich --- generic/lib/systemd/ifupdown-prepare | 2 ++ .../lib/systemd/system/ifupdown-prepare.service | 11 +++++++++++ generic/lib/systemd/system/ifupdown.service | 10 ++++++++++ rules/initmethod-systemd.in | 16 +++++++++++++++ rules/initmethod-systemd.make | 23 ++++++++++++++++++++++ 5 files changed, 62 insertions(+) create mode 100755 generic/lib/systemd/ifupdown-prepare create mode 100644 generic/lib/systemd/system/ifupdown-prepare.service create mode 100644 generic/lib/systemd/system/ifupdown.service create mode 100644 rules/initmethod-systemd.in 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) -- cgit v1.2.3