diff options
Diffstat (limited to 'net-firewall/nftables/files/nftables-mk.init-r1')
-rw-r--r-- | net-firewall/nftables/files/nftables-mk.init-r1 | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/net-firewall/nftables/files/nftables-mk.init-r1 b/net-firewall/nftables/files/nftables-mk.init-r1 index 45b2abdbda77..1f03301c0535 100644 --- a/net-firewall/nftables/files/nftables-mk.init-r1 +++ b/net-firewall/nftables/files/nftables-mk.init-r1 @@ -20,7 +20,7 @@ checkkernel() { } checkconfig() { - if [ -z "${NFTABLES_SAVE}" -o ! -f "${NFTABLES_SAVE}" ] ; then + if [ -z "${NFTABLES_SAVE}" ] || [ ! -f "${NFTABLES_SAVE}" ] ; then eerror "Not starting nftables. First create some rules then run:" eerror "/etc/init.d/${SVCNAME} save" return 1 @@ -28,6 +28,11 @@ checkconfig() { return 0 } +_nftables() { + export NFTABLES_SAVE SAVE_OPTIONS + /usr/libexec/nftables/nftables.sh "${@}" +} + start_pre() { checkconfig || return 1 checkkernel || return 1 @@ -36,8 +41,8 @@ start_pre() { start() { ebegin "Loading ${SVCNAME} state and starting firewall" - /usr/libexec/nftables/nftables.sh load "${NFTABLES_SAVE}" - eend $? + _nftables load "${NFTABLES_SAVE}" + eend ${?} } stop() { @@ -47,13 +52,13 @@ stop() { ebegin "Stopping firewall" if [ "${PANIC_ON_STOP}" = "hard" ]; then - /usr/libexec/nftables/nftables.sh panic + _nftables panic elif [ "${PANIC_ON_STOP}" = "soft" ]; then - /usr/libexec/nftables/nftables.sh soft_panic + _nftables soft_panic else - /usr/libexec/nftables/nftables.sh clear + _nftables clear fi - eend $? + eend ${?} } reload() { @@ -63,43 +68,42 @@ reload() { clear() { ebegin "Clearing rules" - /usr/libexec/nftables/nftables.sh clear - eend $? + _nftables clear + eend ${?} } list() { - /usr/libexec/nftables/nftables.sh list + _nftables list } check() { ebegin "Checking rules" - /usr/libexec/nftables/nftables.sh check "${NFTABLES_SAVE}" - eend $? + _nftables 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 $? + _nftables store "${NFTABLES_SAVE}" + eend ${?} } panic() { - if service_started ${SVCNAME}; then - rc-service ${SVCNAME} zap + if service_started "${SVCNAME}"; then + rc-service "${SVCNAME}" zap fi ebegin "Dropping all packets" - /usr/libexec/nftables/nftables.sh panic - eend $? + _nftables panic + eend ${?} } soft_panic() { - if service_started ${SVCNAME}; then - rc-service ${SVCNAME} zap + if service_started "${SVCNAME}"; then + rc-service "${SVCNAME}" zap fi ebegin "Dropping new connections" - /usr/libexec/nftables/nftables.sh soft_panic - eend $? + _nftables soft_panic + eend ${?} } |