From 18bb804ba9d4daf364b9e740735b8576f6c78e76 Mon Sep 17 00:00:00 2001 From: "Christian W. Zuckschwerdt" Date: Mon, 14 Jun 2021 17:57:55 +0200 Subject: net-firewall/nfacct: add init script Closes: https://bugs.gentoo.org/796707 Signed-off-by: Christian W. Zuckschwerdt Closes: https://github.com/gentoo/gentoo/pull/21237 Signed-off-by: Sam James --- net-firewall/nfacct/files/nfacct.confd | 7 +++++ net-firewall/nfacct/files/nfacct.initd | 42 ++++++++++++++++++++++++++++++ net-firewall/nfacct/nfacct-1.0.2-r1.ebuild | 32 +++++++++++++++++++++++ net-firewall/nfacct/nfacct-1.0.2.ebuild | 24 ----------------- 4 files changed, 81 insertions(+), 24 deletions(-) create mode 100644 net-firewall/nfacct/files/nfacct.confd create mode 100644 net-firewall/nfacct/files/nfacct.initd create mode 100644 net-firewall/nfacct/nfacct-1.0.2-r1.ebuild delete mode 100644 net-firewall/nfacct/nfacct-1.0.2.ebuild (limited to 'net-firewall') diff --git a/net-firewall/nfacct/files/nfacct.confd b/net-firewall/nfacct/files/nfacct.confd new file mode 100644 index 000000000000..b695251ebb03 --- /dev/null +++ b/net-firewall/nfacct/files/nfacct.confd @@ -0,0 +1,7 @@ +# /etc/conf.d/nfacct + +# Location for nfacct initscript to save and restore the counters +NFACCT_SAVE="/var/lib/nfacct/counters-save" + +# Save counters on stopping nfacct +SAVE_ON_STOP="yes" diff --git a/net-firewall/nfacct/files/nfacct.initd b/net-firewall/nfacct/files/nfacct.initd new file mode 100644 index 000000000000..ac5eeaa33aba --- /dev/null +++ b/net-firewall/nfacct/files/nfacct.initd @@ -0,0 +1,42 @@ +#!/sbin/openrc-run +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +extra_commands="save" + +NFACCT_SAVE=${NFACCT_SAVE:-/var/lib/nfacct/counters-save} + +depend() { + before iptables ip6tables +} + +checkconfig() { + if [ ! -f "${NFACCT_SAVE}" ] ; then + eerror "Not starting ${SVCNAME}. First create some counters then run:" + eerror "/etc/init.d/${SVCNAME} save" + return 1 + fi + return 0 +} + +start() { + checkconfig || return 1 + ebegin "Loading nfacct counters" + nfacct restore < "${NFACCT_SAVE}" + eend $? +} + +stop() { + if [ "${SAVE_ON_STOP}" = "yes" ] ; then + save || return 1 + fi + ebegin "Removing nfacct counters" + nfacct flush + eend $? +} + +save() { + ebegin "Saving nfacct counters" + nfacct list > "${NFACCT_SAVE}" + eend $? +} diff --git a/net-firewall/nfacct/nfacct-1.0.2-r1.ebuild b/net-firewall/nfacct/nfacct-1.0.2-r1.ebuild new file mode 100644 index 000000000000..1feb53596a4b --- /dev/null +++ b/net-firewall/nfacct/nfacct-1.0.2-r1.ebuild @@ -0,0 +1,32 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 +inherit linux-info + +DESCRIPTION="Command line tool to create/retrieve/delete accounting objects in NetFilter" +HOMEPAGE="https://www.netfilter.org/projects/nfacct/" +SRC_URI="https://www.netfilter.org/projects/${PN}/files/${P}.tar.bz2" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="amd64 ~arm ~ppc64 x86" + +RDEPEND=" + net-libs/libmnl + >=net-libs/libnetfilter_acct-1.0.3 +" +DEPEND=" + ${RDEPEND} + virtual/pkgconfig +" + +CONFIG_CHECK="~NETFILTER_NETLINK_ACCT" + +src_install() { + default_src_install + + keepdir /var/lib/nfacct + newinitd "${FILESDIR}"/${PN}.initd nfacct + newconfd "${FILESDIR}"/${PN}.confd nfacct +} diff --git a/net-firewall/nfacct/nfacct-1.0.2.ebuild b/net-firewall/nfacct/nfacct-1.0.2.ebuild deleted file mode 100644 index e8f02e4ce7f0..000000000000 --- a/net-firewall/nfacct/nfacct-1.0.2.ebuild +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=6 -inherit linux-info - -DESCRIPTION="Command line tool to create/retrieve/delete accounting objects in NetFilter" -HOMEPAGE="https://www.netfilter.org/projects/nfacct/" -SRC_URI="https://www.netfilter.org/projects/${PN}/files/${P}.tar.bz2" - -LICENSE="GPL-2" -SLOT="0" -KEYWORDS="amd64 ~arm ~ppc64 x86" - -RDEPEND=" - net-libs/libmnl - >=net-libs/libnetfilter_acct-1.0.3 -" -DEPEND=" - ${RDEPEND} - virtual/pkgconfig -" - -CONFIG_CHECK="~NETFILTER_NETLINK_ACCT" -- cgit v1.2.3-65-gdbad