From d178bf5d35417141a201e9ada7d04e912e4d2d7d Mon Sep 17 00:00:00 2001 From: Dirk Brenken Date: Wed, 12 Apr 2023 15:31:31 +0200 Subject: [PATCH] banip: update 0.8.3-2 * more init fixes Signed-off-by: Dirk Brenken --- net/banip/Makefile | 2 +- net/banip/files/banip-functions.sh | 25 ++++++++++++++++--------- net/banip/files/banip.init | 5 ++--- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/net/banip/Makefile b/net/banip/Makefile index d2e54a2ad1..eabaadb58e 100644 --- a/net/banip/Makefile +++ b/net/banip/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=banip PKG_VERSION:=0.8.3 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_LICENSE:=GPL-3.0-or-later PKG_MAINTAINER:=Dirk Brenken diff --git a/net/banip/files/banip-functions.sh b/net/banip/files/banip-functions.sh index 991d1147e8..3b485e3bdf 100644 --- a/net/banip/files/banip-functions.sh +++ b/net/banip/files/banip-functions.sh @@ -78,7 +78,10 @@ ban_debug="0" f_system() { local cpu core - [ -z "${ban_dev}" ] && ban_cores="$(uci_get banip global ban_cores)" + if [ -z "${ban_dev}" ]; then + ban_debug="$(uci_get banip global ban_debug)" + ban_cores="$(uci_get banip global ban_cores)" + fi ban_memory="$("${ban_awkcmd}" '/^MemAvailable/{printf "%s",int($2/1000)}' "/proc/meminfo" 2>/dev/null)" ban_ver="$(${ban_ubuscmd} -S call rpc-sys packagelist '{ "all": true }' 2>/dev/null | jsonfilter -ql1 -e '@.packages.banip')" ban_sysver="$(${ban_ubuscmd} -S call system board 2>/dev/null | jsonfilter -ql1 -e '@.model' -e '@.release.description' | @@ -1282,17 +1285,21 @@ f_mail() { f_log "debug" "f_mail ::: notification: ${ban_mailnotification}, template: ${ban_mailtemplate}, profile: ${ban_mailprofile}, receiver: ${ban_mailreceiver}, rc: ${?}" } -# check banIP availability and initial sourcing +# initial sourcing +# +if [ -r "/lib/functions.sh" ] && [ -r "/lib/functions/network.sh" ] && [ -r "/usr/share/libubox/jshn.sh" ]; then + . "/lib/functions.sh" + . "/lib/functions/network.sh" + . "/usr/share/libubox/jshn.sh" +else + rm -rf "${ban_lock}" + exit 1 +fi + +# check banIP availability # f_system if [ "${ban_action}" != "stop" ]; then - if [ -r "/lib/functions.sh" ] && [ -r "/lib/functions/network.sh" ] && [ -r "/usr/share/libubox/jshn.sh" ]; then - . "/lib/functions.sh" - . "/lib/functions/network.sh" - . "/usr/share/libubox/jshn.sh" - else - f_log "err" "system libraries not found" - fi [ ! -d "/etc/banip" ] && f_log "err" "banIP config directory not found, please re-install the package" [ ! -r "/etc/banip/banip.feeds" ] && f_log "err" "banIP feed file not found, please re-install the package" [ ! -r "/etc/config/banip" ] && f_log "err" "banIP config not found, please re-install the package" diff --git a/net/banip/files/banip.init b/net/banip/files/banip.init index 6822a1bcb2..891dee4eb0 100755 --- a/net/banip/files/banip.init +++ b/net/banip/files/banip.init @@ -20,9 +20,8 @@ ban_funlib="/usr/lib/banip-functions.sh" ban_pidfile="/var/run/banip.pid" ban_lock="/var/run/banip.lock" -[ "${action}" = "boot" ] && /etc/init.d/banip running && exit 0 -{ [ "${action}" = "stop" ] || [ "${action}" = "lookup" ]; } && ! /etc/init.d/banip running && exit 0 -[ ! -r "${ban_funlib}" ] && [ "${action}" != "boot" ] && exit 1 +[ "${action}" = "boot" ] && "${ban_init}" running && exit 0 +{ [ "${action}" = "stop" ] || [ "${action}" = "report" ] || [ "${action}" = "search" ] || [ "${action}" = "survey" ] || [ "${action}" = "lookup" ]; } && ! "${ban_init}" running && exit 0 [ -d "${ban_lock}" ] && { [ "${action}" = "start" ] || [ "${action}" = "restart" ] || [ "${action}" = "reload" ] || [ "${action}" = "lookup" ]; } && exit 1 [ ! -d "${ban_lock}" ] && { [ "${action}" = "start" ] || [ "${action}" = "restart" ] || [ "${action}" = "reload" ] || [ "${action}" = "lookup" ]; } && mkdir -p "${ban_lock}" -- 2.30.2