banip: update to 0.8.2-5
* fixed missing version number when installed as separate package (not in build) * fixed cornercase init and mailing issues * sorted Country list by country names ascending * fixed some shellcheck findings Signed-off-by: Dirk Brenken <dev@brenken.org>
This commit is contained in:
parent
797f7b44aa
commit
c9bf92c88d
5 changed files with 42 additions and 33 deletions
|
@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=banip
|
PKG_NAME:=banip
|
||||||
PKG_VERSION:=0.8.2
|
PKG_VERSION:=0.8.2
|
||||||
PKG_RELEASE:=4
|
PKG_RELEASE:=5
|
||||||
PKG_LICENSE:=GPL-3.0-or-later
|
PKG_LICENSE:=GPL-3.0-or-later
|
||||||
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
|
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ f_system() {
|
||||||
local cpu core
|
local cpu core
|
||||||
|
|
||||||
ban_memory="$("${ban_awkcmd}" '/^MemAvailable/{printf "%s",int($2/1000)}' "/proc/meminfo" 2>/dev/null)"
|
ban_memory="$("${ban_awkcmd}" '/^MemAvailable/{printf "%s",int($2/1000)}' "/proc/meminfo" 2>/dev/null)"
|
||||||
ban_ver="$(${ban_ubuscmd} -S call rpc-sys packagelist 2>/dev/null | jsonfilter -ql1 -e '@.packages.banip')"
|
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' |
|
ban_sysver="$(${ban_ubuscmd} -S call system board 2>/dev/null | jsonfilter -ql1 -e '@.model' -e '@.release.description' |
|
||||||
"${ban_awkcmd}" 'BEGIN{RS="";FS="\n"}{printf "%s, %s",$1,$2}')"
|
"${ban_awkcmd}" 'BEGIN{RS="";FS="\n"}{printf "%s, %s",$1,$2}')"
|
||||||
if [ -z "${ban_cores}" ]; then
|
if [ -z "${ban_cores}" ]; then
|
||||||
|
@ -928,7 +928,7 @@ f_genstatus() {
|
||||||
# get status information
|
# get status information
|
||||||
#
|
#
|
||||||
f_getstatus() {
|
f_getstatus() {
|
||||||
local key keylist type value index_key1 index_key2 index_value1 index_value2 actual="${1}"
|
local key keylist type value index_key1 index_key2 index_value1 index_value2
|
||||||
|
|
||||||
[ -z "${ban_dev}" ] && f_conf
|
[ -z "${ban_dev}" ] && f_conf
|
||||||
json_load_file "${ban_rtfile}" >/dev/null 2>&1
|
json_load_file "${ban_rtfile}" >/dev/null 2>&1
|
||||||
|
@ -1262,7 +1262,11 @@ f_mail() {
|
||||||
|
|
||||||
# load mail template
|
# load mail template
|
||||||
#
|
#
|
||||||
[ -r "${ban_mailtemplate}" ] && . "${ban_mailtemplate}" || f_log "info" "the mail template is missing"
|
if [ -r "${ban_mailtemplate}" ]; then
|
||||||
|
. "${ban_mailtemplate}"
|
||||||
|
else
|
||||||
|
f_log "info" "the mail template is missing"
|
||||||
|
fi
|
||||||
[ -z "${mail_text}" ] && f_log "info" "the 'mail_text' template variable is empty"
|
[ -z "${mail_text}" ] && f_log "info" "the 'mail_text' template variable is empty"
|
||||||
[ "${ban_debug}" = "1" ] && msmtp_debug="--debug"
|
[ "${ban_debug}" = "1" ] && msmtp_debug="--debug"
|
||||||
|
|
||||||
|
|
|
@ -138,8 +138,13 @@ hold="$((cnt % ban_cores))"
|
||||||
f_rmset
|
f_rmset
|
||||||
f_rmdir "${ban_tmpdir}"
|
f_rmdir "${ban_tmpdir}"
|
||||||
f_genstatus "active"
|
f_genstatus "active"
|
||||||
[ "${ban_mailnotification}" = "1" ] && [ -n "${ban_mailreceiver}" ] && [ -x "${ban_mailcmd}" ] && f_mail
|
|
||||||
f_log "info" "finished banIP download processes"
|
f_log "info" "finished banIP download processes"
|
||||||
|
if [ "${ban_mailnotification}" = "1" ] && [ -n "${ban_mailreceiver}" ] && [ -x "${ban_mailcmd}" ]; then
|
||||||
|
(
|
||||||
|
sleep ${ban_triggerdelay}
|
||||||
|
f_mail
|
||||||
|
) &
|
||||||
|
fi
|
||||||
rm -rf "${ban_lock}"
|
rm -rf "${ban_lock}"
|
||||||
|
|
||||||
# start detached log service
|
# start detached log service
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
tw;Taiwan
|
|
||||||
af;Afghanistan
|
af;Afghanistan
|
||||||
|
ax;Åland Islands
|
||||||
al;Albania
|
al;Albania
|
||||||
dz;Algeria
|
dz;Algeria
|
||||||
as;American Samoa
|
as;American Samoa
|
||||||
|
@ -25,7 +25,6 @@ bj;Benin
|
||||||
bm;Bermuda
|
bm;Bermuda
|
||||||
bt;Bhutan
|
bt;Bhutan
|
||||||
bo;Bolivia
|
bo;Bolivia
|
||||||
bq;Caribbean Netherlands
|
|
||||||
ba;Bosnia
|
ba;Bosnia
|
||||||
bw;Botswana
|
bw;Botswana
|
||||||
bv;Bouvet Island
|
bv;Bouvet Island
|
||||||
|
@ -36,32 +35,30 @@ bn;Brunei
|
||||||
bg;Bulgaria
|
bg;Bulgaria
|
||||||
bf;Burkina Faso
|
bf;Burkina Faso
|
||||||
bi;Burundi
|
bi;Burundi
|
||||||
cv;Cape Verde
|
|
||||||
kh;Cambodia
|
kh;Cambodia
|
||||||
cm;Cameroon
|
cm;Cameroon
|
||||||
ca;Canada
|
ca;Canada
|
||||||
|
cv;Cape Verde
|
||||||
|
bq;Caribbean Netherlands
|
||||||
ky;Cayman Islands
|
ky;Cayman Islands
|
||||||
cf;Central African Republic
|
cf;Central African Republic
|
||||||
td;Chad
|
td;Chad
|
||||||
cl;Chile
|
cl;Chile
|
||||||
cn;China
|
cn;China
|
||||||
hk;Hong Kong
|
|
||||||
mo;Macau
|
|
||||||
cx;Christmas Island
|
cx;Christmas Island
|
||||||
cc;Cocos (Keeling) Islands
|
cc;Cocos (Keeling) Islands
|
||||||
co;Colombia
|
co;Colombia
|
||||||
km;Comoros
|
km;Comoros
|
||||||
cg;Congo - Brazzaville
|
cg;Congo - Brazzaville
|
||||||
|
cd;Congo - Kinshasa
|
||||||
ck;Cook Islands
|
ck;Cook Islands
|
||||||
cr;Costa Rica
|
cr;Costa Rica
|
||||||
|
ci;Côte d’Ivoire
|
||||||
hr;Croatia
|
hr;Croatia
|
||||||
cu;Cuba
|
cu;Cuba
|
||||||
cw;Curaçao
|
cw;Curaçao
|
||||||
cy;Cyprus
|
cy;Cyprus
|
||||||
cz;Czechia
|
cz;Czechia
|
||||||
ci;Côte d’Ivoire
|
|
||||||
kp;North Korea
|
|
||||||
cd;Congo - Kinshasa
|
|
||||||
dk;Denmark
|
dk;Denmark
|
||||||
dj;Djibouti
|
dj;Djibouti
|
||||||
dm;Dominica
|
dm;Dominica
|
||||||
|
@ -100,8 +97,8 @@ gw;Guinea-Bissau
|
||||||
gy;Guyana
|
gy;Guyana
|
||||||
ht;Haiti
|
ht;Haiti
|
||||||
hm;Heard & McDonald Islands
|
hm;Heard & McDonald Islands
|
||||||
va;Vatican City
|
|
||||||
hn;Honduras
|
hn;Honduras
|
||||||
|
hk;Hong Kong
|
||||||
hu;Hungary
|
hu;Hungary
|
||||||
is;Iceland
|
is;Iceland
|
||||||
in;India
|
in;India
|
||||||
|
@ -130,6 +127,7 @@ ly;Libya
|
||||||
li;Liechtenstein
|
li;Liechtenstein
|
||||||
lt;Lithuania
|
lt;Lithuania
|
||||||
lu;Luxembourg
|
lu;Luxembourg
|
||||||
|
mo;Macau
|
||||||
mg;Madagascar
|
mg;Madagascar
|
||||||
mw;Malawi
|
mw;Malawi
|
||||||
my;Malaysia
|
my;Malaysia
|
||||||
|
@ -143,6 +141,7 @@ mu;Mauritius
|
||||||
yt;Mayotte
|
yt;Mayotte
|
||||||
mx;Mexico
|
mx;Mexico
|
||||||
fm;Micronesia
|
fm;Micronesia
|
||||||
|
md;Moldova
|
||||||
mc;Monaco
|
mc;Monaco
|
||||||
mn;Mongolia
|
mn;Mongolia
|
||||||
me;Montenegro
|
me;Montenegro
|
||||||
|
@ -162,10 +161,13 @@ ng;Nigeria
|
||||||
nu;Niue
|
nu;Niue
|
||||||
nf;Norfolk Island
|
nf;Norfolk Island
|
||||||
mp;Northern Mariana Islands
|
mp;Northern Mariana Islands
|
||||||
|
kp;North Korea
|
||||||
|
mk;North Macedonia
|
||||||
no;Norway
|
no;Norway
|
||||||
om;Oman
|
om;Oman
|
||||||
pk;Pakistan
|
pk;Pakistan
|
||||||
pw;Palau
|
pw;Palau
|
||||||
|
ps;Palestine
|
||||||
pa;Panama
|
pa;Panama
|
||||||
pg;Papua New Guinea
|
pg;Papua New Guinea
|
||||||
py;Paraguay
|
py;Paraguay
|
||||||
|
@ -176,19 +178,10 @@ pl;Poland
|
||||||
pt;Portugal
|
pt;Portugal
|
||||||
pr;Puerto Rico
|
pr;Puerto Rico
|
||||||
qa;Qatar
|
qa;Qatar
|
||||||
kr;South Korea
|
re;Réunion
|
||||||
md;Moldova
|
|
||||||
ro;Romania
|
ro;Romania
|
||||||
ru;Russia
|
ru;Russia
|
||||||
rw;Rwanda
|
rw;Rwanda
|
||||||
re;Réunion
|
|
||||||
bl;St. Barthélemy
|
|
||||||
sh;St. Helena
|
|
||||||
kn;St. Kitts & Nevis
|
|
||||||
lc;St. Lucia
|
|
||||||
mf;St. Martin
|
|
||||||
pm;St. Pierre & Miquelon
|
|
||||||
vc;St. Vincent & Grenadines
|
|
||||||
ws;Samoa
|
ws;Samoa
|
||||||
sm;San Marino
|
sm;San Marino
|
||||||
st;São Tomé & Príncipe
|
st;São Tomé & Príncipe
|
||||||
|
@ -205,19 +198,27 @@ sb;Solomon Islands
|
||||||
so;Somalia
|
so;Somalia
|
||||||
za;South Africa
|
za;South Africa
|
||||||
gs;South Georgia & South Sandwich Islands
|
gs;South Georgia & South Sandwich Islands
|
||||||
|
kr;South Korea
|
||||||
ss;South Sudan
|
ss;South Sudan
|
||||||
es;Spain
|
es;Spain
|
||||||
lk;Sri Lanka
|
lk;Sri Lanka
|
||||||
ps;Palestine
|
bl;St. Barthélemy
|
||||||
|
sh;St. Helena
|
||||||
|
kn;St. Kitts & Nevis
|
||||||
|
lc;St. Lucia
|
||||||
|
mf;St. Martin
|
||||||
|
pm;St. Pierre & Miquelon
|
||||||
|
vc;St. Vincent & Grenadines
|
||||||
sd;Sudan
|
sd;Sudan
|
||||||
sr;Suriname
|
sr;Suriname
|
||||||
sj;Svalbard & Jan Mayen
|
sj;Svalbard & Jan Mayen
|
||||||
se;Sweden
|
se;Sweden
|
||||||
ch;Switzerland
|
ch;Switzerland
|
||||||
sy;Syria
|
sy;Syria
|
||||||
|
tw;Taiwan
|
||||||
tj;Tajikistan
|
tj;Tajikistan
|
||||||
|
tz;Tanzania
|
||||||
th;Thailand
|
th;Thailand
|
||||||
mk;North Macedonia
|
|
||||||
tl;Timor-Leste
|
tl;Timor-Leste
|
||||||
tg;Togo
|
tg;Togo
|
||||||
tk;Tokelau
|
tk;Tokelau
|
||||||
|
@ -232,13 +233,13 @@ ug;Uganda
|
||||||
ua;Ukraine
|
ua;Ukraine
|
||||||
ae;United Arab Emirates
|
ae;United Arab Emirates
|
||||||
gb;United Kingdom
|
gb;United Kingdom
|
||||||
tz;Tanzania
|
|
||||||
um;U.S. Outlying Islands
|
|
||||||
vi;U.S. Virgin Islands
|
|
||||||
us;United States
|
us;United States
|
||||||
uy;Uruguay
|
uy;Uruguay
|
||||||
|
um;U.S. Outlying Islands
|
||||||
|
vi;U.S. Virgin Islands
|
||||||
uz;Uzbekistan
|
uz;Uzbekistan
|
||||||
vu;Vanuatu
|
vu;Vanuatu
|
||||||
|
va;Vatican City
|
||||||
ve;Venezuela
|
ve;Venezuela
|
||||||
vn;Vietnam
|
vn;Vietnam
|
||||||
wf;Wallis & Futuna
|
wf;Wallis & Futuna
|
||||||
|
@ -246,4 +247,3 @@ eh;Western Sahara
|
||||||
ye;Yemen
|
ye;Yemen
|
||||||
zm;Zambia
|
zm;Zambia
|
||||||
zw;Zimbabwe
|
zw;Zimbabwe
|
||||||
ax;Åland Islands
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ ban_funlib="/usr/lib/banip-functions.sh"
|
||||||
ban_pidfile="/var/run/banip.pid"
|
ban_pidfile="/var/run/banip.pid"
|
||||||
ban_lock="/var/run/banip.lock"
|
ban_lock="/var/run/banip.lock"
|
||||||
|
|
||||||
|
[ "${action}" = "boot" ] && /etc/init.d/banip running && exit 0
|
||||||
[ "${action}" = "stop" ] && ! /etc/init.d/banip running && exit 0
|
[ "${action}" = "stop" ] && ! /etc/init.d/banip running && exit 0
|
||||||
[ ! -r "${ban_funlib}" ] && { [ "${action}" = "start" ] || [ "${action}" = "restart" ] || [ "${action}" = "reload" ] || [ "${action}" = "stop" ] || [ "${action}" = "report" ] || [ "${action}" = "search" ] || [ "${action}" = "survey" ] || [ "${action}" = "status" ]; } && exit 1
|
[ ! -r "${ban_funlib}" ] && { [ "${action}" = "start" ] || [ "${action}" = "restart" ] || [ "${action}" = "reload" ] || [ "${action}" = "stop" ] || [ "${action}" = "report" ] || [ "${action}" = "search" ] || [ "${action}" = "survey" ] || [ "${action}" = "status" ]; } && exit 1
|
||||||
[ -d "${ban_lock}" ] && { [ "${action}" = "start" ] || [ "${action}" = "restart" ] || [ "${action}" = "reload" ]; } && exit 1
|
[ -d "${ban_lock}" ] && { [ "${action}" = "start" ] || [ "${action}" = "restart" ] || [ "${action}" = "reload" ]; } && exit 1
|
||||||
|
@ -60,6 +61,7 @@ stop_service() {
|
||||||
"${ban_nftcmd}" delete table inet banIP >/dev/null 2>&1
|
"${ban_nftcmd}" delete table inet banIP >/dev/null 2>&1
|
||||||
f_genstatus "stopped"
|
f_genstatus "stopped"
|
||||||
f_rmpid
|
f_rmpid
|
||||||
|
rm -rf "${ban_lock}"
|
||||||
}
|
}
|
||||||
|
|
||||||
restart() {
|
restart() {
|
||||||
|
@ -72,10 +74,8 @@ status() {
|
||||||
}
|
}
|
||||||
|
|
||||||
status_service() {
|
status_service() {
|
||||||
local actual="${1}"
|
|
||||||
|
|
||||||
[ -z "$(command -v "f_system")" ] && . "${ban_funlib}"
|
[ -z "$(command -v "f_system")" ] && . "${ban_funlib}"
|
||||||
[ -n "${actual}" ] && f_actual || f_getstatus
|
f_getstatus
|
||||||
}
|
}
|
||||||
|
|
||||||
report() {
|
report() {
|
||||||
|
|
Loading…
Reference in a new issue