summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick McLean <chutzpah@gentoo.org>2020-09-29 10:03:26 -0700
committerPatrick McLean <chutzpah@gentoo.org>2020-09-29 10:04:18 -0700
commitadfc1a4934b84b1325a635602ddee175389f3bde (patch)
tree59a3c05cde907eafa44a53bb7f5bdcb82bd3db7b /net-firewall/nftables
parentapp-text/coolreader: bump to 3.2.49 (diff)
downloadgentoo-adfc1a4934b84b1325a635602ddee175389f3bde.tar.gz
gentoo-adfc1a4934b84b1325a635602ddee175389f3bde.tar.bz2
gentoo-adfc1a4934b84b1325a635602ddee175389f3bde.zip
net-firewall/nftables-0.9.6-r1: Add bump of mk script (bug #745381)
Closes: https://bugs.gentoo.org/745381 Package-Manager: Portage-3.0.8, Repoman-3.0.1 Signed-off-by: Patrick McLean <chutzpah@gentoo.org>
Diffstat (limited to 'net-firewall/nftables')
-rw-r--r--net-firewall/nftables/files/nftables-mk.init-r1105
1 files changed, 105 insertions, 0 deletions
diff --git a/net-firewall/nftables/files/nftables-mk.init-r1 b/net-firewall/nftables/files/nftables-mk.init-r1
new file mode 100644
index 000000000000..45b2abdbda77
--- /dev/null
+++ b/net-firewall/nftables/files/nftables-mk.init-r1
@@ -0,0 +1,105 @@
+#!/sbin/openrc-run
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+extra_commands="check clear list panic save soft_panic"
+extra_started_commands="reload"
+
+depend() {
+ need localmount #434774
+ before net
+}
+
+checkkernel() {
+ if ! /sbin/nft list ruleset >/dev/null 2>/dev/null ; then
+ eerror "Your kernel lacks nftables support, please load"
+ eerror "appropriate modules and try again."
+ return 1
+ fi
+ return 0
+}
+
+checkconfig() {
+ if [ -z "${NFTABLES_SAVE}" -o ! -f "${NFTABLES_SAVE}" ] ; then
+ eerror "Not starting nftables. First create some rules then run:"
+ eerror "/etc/init.d/${SVCNAME} save"
+ return 1
+ fi
+ return 0
+}
+
+start_pre() {
+ checkconfig || return 1
+ checkkernel || return 1
+ check || return 1
+}
+
+start() {
+ ebegin "Loading ${SVCNAME} state and starting firewall"
+ /usr/libexec/nftables/nftables.sh load "${NFTABLES_SAVE}"
+ eend $?
+}
+
+stop() {
+ if [ "${SAVE_ON_STOP}" = "yes" ] ; then
+ save || return 1
+ fi
+
+ ebegin "Stopping firewall"
+ if [ "${PANIC_ON_STOP}" = "hard" ]; then
+ /usr/libexec/nftables/nftables.sh panic
+ elif [ "${PANIC_ON_STOP}" = "soft" ]; then
+ /usr/libexec/nftables/nftables.sh soft_panic
+ else
+ /usr/libexec/nftables/nftables.sh clear
+ fi
+ eend $?
+}
+
+reload() {
+ start_pre || return 1
+ start
+}
+
+clear() {
+ ebegin "Clearing rules"
+ /usr/libexec/nftables/nftables.sh clear
+ eend $?
+}
+
+list() {
+ /usr/libexec/nftables/nftables.sh list
+}
+
+check() {
+ ebegin "Checking rules"
+ /usr/libexec/nftables/nftables.sh check "${NFTABLES_SAVE}"
+ eend $?
+}
+
+save() {
+ ebegin "Saving ${SVCNAME} state"
+ checkpath -q -d "$(dirname "${NFTABLES_SAVE}")"
+ checkpath -q -m 0600 -f "${NFTABLES_SAVE}"
+ SAVE_OPTIONS="${SAVE_OPTIONS}" \
+ /usr/libexec/nftables/nftables.sh store "${NFTABLES_SAVE}"
+ eend $?
+}
+
+panic() {
+ if service_started ${SVCNAME}; then
+ rc-service ${SVCNAME} zap
+ fi
+ ebegin "Dropping all packets"
+ /usr/libexec/nftables/nftables.sh panic
+ eend $?
+}
+
+soft_panic() {
+ if service_started ${SVCNAME}; then
+ rc-service ${SVCNAME} zap
+ fi
+ ebegin "Dropping new connections"
+ /usr/libexec/nftables/nftables.sh soft_panic
+ eend $?
+}