arptables: add arptables systemd service file

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@windriver.com>
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
This commit is contained in:
Li Zhou
2016-09-26 10:24:28 +08:00
committed by Joe MacDonald
parent 93b0d65793
commit a0e2240e0a
2 changed files with 26 additions and 0 deletions

View File

@@ -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

View File

@@ -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"