mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: "Baeuerle, Florian" <Florian.Baeuerle@allegion.com>
To: "ptxdist@pengutronix.de" <ptxdist@pengutronix.de>
Subject: [ptxdist] [PATCH] nftables: add option for installing systemd unit
Date: Wed, 3 Apr 2019 14:12:04 +0000	[thread overview]
Message-ID: <20190403141142.3743-1-florian.baeuerle@allegion.com> (raw)

Allow installing a systemd unit for loading the nftables configuration
file. The systemd unit is taken from Arch Linux.

Signed-off-by: Florian Bäuerle <florian.baeuerle@allegion.com>
---
 .../usr/lib/systemd/system/nftables.service       | 15 +++++++++++++++
 rules/nftables.in                                 |  6 ++++++
 rules/nftables.make                               |  6 ++++++
 3 files changed, 27 insertions(+)
 create mode 100644 projectroot/usr/lib/systemd/system/nftables.service

diff --git a/projectroot/usr/lib/systemd/system/nftables.service b/projectroot/usr/lib/systemd/system/nftables.service
new file mode 100644
index 000000000..16f390d6a
--- /dev/null
+++ b/projectroot/usr/lib/systemd/system/nftables.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Netfilter Tables
+Documentation=man:nft(8)
+Wants=network-pre.target
+Before=network-pre.target
+
+[Service]
+Type=oneshot
+ExecStart=/usr/sbin/nft -f /etc/nftables.conf
+ExecReload=/usr/sbin/nft flush ruleset ';' include '"/etc/nftables.conf"'
+ExecStop=/usr/sbin/nft flush ruleset
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target
diff --git a/rules/nftables.in b/rules/nftables.in
index aafd7cdd6..089f68d2e 100644
--- a/rules/nftables.in
+++ b/rules/nftables.in
@@ -36,4 +36,10 @@ config NFTABLES_STARTSCRIPT
 	bool
 	prompt "install /etc/init.d/nftables"
 
+config NFTABLES_SYSTEMD_UNIT
+	bool
+	default y
+	depends on INITMETHOD_SYSTEMD
+	prompt "install systemd unit file for nftables"
+
 endif
diff --git a/rules/nftables.make b/rules/nftables.make
index 4a95694ad..15368f965 100644
--- a/rules/nftables.make
+++ b/rules/nftables.make
@@ -69,6 +69,12 @@ endif
 endif
 endif
 
+ifdef PTXCONF_NFTABLES_SYSTEMD_UNIT
+	@$(call install_alternative, nftables, 0, 0, 0644, /usr/lib/systemd/system/nftables.service)
+	@$(call install_link, nftables, ../nftables.service, \
+		/usr/lib/systemd/system/multi-user.target.wants/nftables.service)
+endif
+
 	@$(call install_finish, nftables)
 
 	@$(call touch)
-- 
2.21.0

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

             reply	other threads:[~2019-04-03 14:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-03 14:12 Baeuerle, Florian [this message]
2019-04-03 16:58 ` Alexander Dahl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190403141142.3743-1-florian.baeuerle@allegion.com \
    --to=florian.baeuerle@allegion.com \
    --cc=ptxdist@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox