[oe] [meta-networking][PATCH] arptables: add arptables systemd service file

Li Zhou li.zhou at windriver.com
Mon Sep 26 02:24:28 UTC 2016


Add arptables systemd service file.
If there isn't any configuration file (/etc/sysconfig/arptables),
add a default configuration file.

Signed-off-by: Li Zhou <li.zhou at windriver.com>
---
 .../arptables/arptables-0.0.3-4/arptables.service        | 16 ++++++++++++++++
 .../recipes-support/arptables/arptables_0.0.3-4.bb       | 10 ++++++++++
 2 files changed, 26 insertions(+)
 create mode 100644 meta-networking/recipes-support/arptables/arptables-0.0.3-4/arptables.service

diff --git a/meta-networking/recipes-support/arptables/arptables-0.0.3-4/arptables.service b/meta-networking/recipes-support/arptables/arptables-0.0.3-4/arptables.service
new file mode 100644
index 0000000..fa64342
--- /dev/null
+++ b/meta-networking/recipes-support/arptables/arptables-0.0.3-4/arptables.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=Arp filtering arptables
+After=network.target
+Requires=network.target
+
+[Service]
+Type=oneshot
+ExecStartPre=/bin/sh -c "if [ ! -f /etc/sysconfig/arptables ]; then /usr/sbin/arptables-save > /etc/sysconfig/arptables; fi"
+ExecStart=/bin/sh -c "/usr/sbin/arptables-restore < /etc/sysconfig/arptables"
+ExecStartPost=/bin/sh -c "touch /var/lock/subsys/arptables"
+RemainAfterExit=yes
+ExecStop=/bin/sh -c "/usr/sbin/arptables-restore < /dev/null"
+ExecStopPost=/bin/sh -c "rm -f /var/lock/subsys/arptables"
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta-networking/recipes-support/arptables/arptables_0.0.3-4.bb b/meta-networking/recipes-support/arptables/arptables_0.0.3-4.bb
index be2ac66..f536408 100644
--- a/meta-networking/recipes-support/arptables/arptables_0.0.3-4.bb
+++ b/meta-networking/recipes-support/arptables/arptables_0.0.3-4.bb
@@ -13,6 +13,7 @@ SRC_URI = " \
     file://arptables-init-busybox.patch \
     file://arptables-arpt-get-target-fix.patch \
     file://arptables-remove-bashism.patch \
+    file://arptables.service \
 "
 SRC_URI[arptables.md5sum] = "1d4ab05761f063b0751645d8f2b8f8e5"
 SRC_URI[arptables.sha256sum] = "e529fd465c67d69ad335299a043516e6b38cdcd337a5ed21718413e96073f928"
@@ -31,3 +32,12 @@ PARALLEL_MAKEINST = "-j1"
 fakeroot do_install () {
     oe_runmake 'BINDIR=${sbindir}' 'MANDIR=${mandir}/' 'DESTDIR=${D}' install
 }
+
+do_install_append() {
+    install -d ${D}${systemd_unitdir}/system
+    install -m 644 ${WORKDIR}/arptables.service ${D}${systemd_unitdir}/system
+}
+
+inherit systemd
+
+SYSTEMD_SERVICE_${PN} = "arptables.service"
-- 
2.9.3




More information about the Openembedded-devel mailing list