diff options
author | Christian W. Zuckschwerdt <christian@zuckschwerdt.org> | 2021-06-14 17:57:55 +0200 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2021-12-03 00:05:40 +0000 |
commit | 18bb804ba9d4daf364b9e740735b8576f6c78e76 (patch) | |
tree | e727d0d0d75842c9720f05483f00d26da4b84e4a /net-firewall | |
parent | dev-scheme/racket: use has_version instead of REPLACING_VERSIONS (diff) | |
download | gentoo-18bb804ba9d4daf364b9e740735b8576f6c78e76.tar.gz gentoo-18bb804ba9d4daf364b9e740735b8576f6c78e76.tar.bz2 gentoo-18bb804ba9d4daf364b9e740735b8576f6c78e76.zip |
net-firewall/nfacct: add init script
Closes: https://bugs.gentoo.org/796707
Signed-off-by: Christian W. Zuckschwerdt <christian@zuckschwerdt.org>
Closes: https://github.com/gentoo/gentoo/pull/21237
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'net-firewall')
-rw-r--r-- | net-firewall/nfacct/files/nfacct.confd | 7 | ||||
-rw-r--r-- | net-firewall/nfacct/files/nfacct.initd | 42 | ||||
-rw-r--r-- | net-firewall/nfacct/nfacct-1.0.2-r1.ebuild (renamed from net-firewall/nfacct/nfacct-1.0.2.ebuild) | 8 |
3 files changed, 57 insertions, 0 deletions
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.ebuild b/net-firewall/nfacct/nfacct-1.0.2-r1.ebuild index e8f02e4ce7f0..1feb53596a4b 100644 --- a/net-firewall/nfacct/nfacct-1.0.2.ebuild +++ b/net-firewall/nfacct/nfacct-1.0.2-r1.ebuild @@ -22,3 +22,11 @@ DEPEND=" " CONFIG_CHECK="~NETFILTER_NETLINK_ACCT" + +src_install() { + default_src_install + + keepdir /var/lib/nfacct + newinitd "${FILESDIR}"/${PN}.initd nfacct + newconfd "${FILESDIR}"/${PN}.confd nfacct +} |