diff options
author | V3n3RiX <venerix@koprulu.sector> | 2021-12-05 02:47:11 +0000 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2021-12-05 02:47:11 +0000 |
commit | 2771f79232c273bc2a57d23bf335dd81ccf6af28 (patch) | |
tree | c8af0fd04194aed03cf067d44e53c7edd3e9ab84 /net-firewall/nfacct/files | |
parent | e9d044d4b9b71200a96adfa280848858c0f468c9 (diff) |
gentoo resync : 05.12.2021
Diffstat (limited to 'net-firewall/nfacct/files')
-rw-r--r-- | net-firewall/nfacct/files/nfacct.confd | 7 | ||||
-rw-r--r-- | net-firewall/nfacct/files/nfacct.initd | 42 |
2 files changed, 49 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 $? +} |