* 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>
(cherry picked from commit
c9bf92c88d771cf4e3bbe851c271f641ff1a0957)
PKG_NAME:=banip
PKG_VERSION:=0.8.2
-PKG_RELEASE:=4
+PKG_RELEASE:=5
PKG_LICENSE:=GPL-3.0-or-later
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
local cpu core
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_awkcmd}" 'BEGIN{RS="";FS="\n"}{printf "%s, %s",$1,$2}')"
if [ -z "${ban_cores}" ]; then
# get status information
#
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
json_load_file "${ban_rtfile}" >/dev/null 2>&1
# 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"
[ "${ban_debug}" = "1" ] && msmtp_debug="--debug"
f_rmset
f_rmdir "${ban_tmpdir}"
f_genstatus "active"
-[ "${ban_mailnotification}" = "1" ] && [ -n "${ban_mailreceiver}" ] && [ -x "${ban_mailcmd}" ] && f_mail
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}"
# start detached log service
-tw;Taiwan
af;Afghanistan
+ax;Åland Islands
al;Albania
dz;Algeria
as;American Samoa
bm;Bermuda
bt;Bhutan
bo;Bolivia
-bq;Caribbean Netherlands
ba;Bosnia
bw;Botswana
bv;Bouvet Island
bg;Bulgaria
bf;Burkina Faso
bi;Burundi
-cv;Cape Verde
kh;Cambodia
cm;Cameroon
ca;Canada
+cv;Cape Verde
+bq;Caribbean Netherlands
ky;Cayman Islands
cf;Central African Republic
td;Chad
cl;Chile
cn;China
-hk;Hong Kong
-mo;Macau
cx;Christmas Island
cc;Cocos (Keeling) Islands
co;Colombia
km;Comoros
cg;Congo - Brazzaville
+cd;Congo - Kinshasa
ck;Cook Islands
cr;Costa Rica
+ci;Côte d’Ivoire
hr;Croatia
cu;Cuba
cw;Curaçao
cy;Cyprus
cz;Czechia
-ci;Côte d’Ivoire
-kp;North Korea
-cd;Congo - Kinshasa
dk;Denmark
dj;Djibouti
dm;Dominica
gy;Guyana
ht;Haiti
hm;Heard & McDonald Islands
-va;Vatican City
hn;Honduras
+hk;Hong Kong
hu;Hungary
is;Iceland
in;India
li;Liechtenstein
lt;Lithuania
lu;Luxembourg
+mo;Macau
mg;Madagascar
mw;Malawi
my;Malaysia
yt;Mayotte
mx;Mexico
fm;Micronesia
+md;Moldova
mc;Monaco
mn;Mongolia
me;Montenegro
nu;Niue
nf;Norfolk Island
mp;Northern Mariana Islands
+kp;North Korea
+mk;North Macedonia
no;Norway
om;Oman
pk;Pakistan
pw;Palau
+ps;Palestine
pa;Panama
pg;Papua New Guinea
py;Paraguay
pt;Portugal
pr;Puerto Rico
qa;Qatar
-kr;South Korea
-md;Moldova
+re;Réunion
ro;Romania
ru;Russia
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
sm;San Marino
st;São Tomé & Príncipe
so;Somalia
za;South Africa
gs;South Georgia & South Sandwich Islands
+kr;South Korea
ss;South Sudan
es;Spain
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
sr;Suriname
sj;Svalbard & Jan Mayen
se;Sweden
ch;Switzerland
sy;Syria
+tw;Taiwan
tj;Tajikistan
+tz;Tanzania
th;Thailand
-mk;North Macedonia
tl;Timor-Leste
tg;Togo
tk;Tokelau
ua;Ukraine
ae;United Arab Emirates
gb;United Kingdom
-tz;Tanzania
-um;U.S. Outlying Islands
-vi;U.S. Virgin Islands
us;United States
uy;Uruguay
+um;U.S. Outlying Islands
+vi;U.S. Virgin Islands
uz;Uzbekistan
vu;Vanuatu
+va;Vatican City
ve;Venezuela
vn;Vietnam
wf;Wallis & Futuna
ye;Yemen
zm;Zambia
zw;Zimbabwe
-ax;Åland Islands
ban_pidfile="/var/run/banip.pid"
ban_lock="/var/run/banip.lock"
+[ "${action}" = "boot" ] && /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
[ -d "${ban_lock}" ] && { [ "${action}" = "start" ] || [ "${action}" = "restart" ] || [ "${action}" = "reload" ]; } && exit 1
"${ban_nftcmd}" delete table inet banIP >/dev/null 2>&1
f_genstatus "stopped"
f_rmpid
+ rm -rf "${ban_lock}"
}
restart() {
}
status_service() {
- local actual="${1}"
-
[ -z "$(command -v "f_system")" ] && . "${ban_funlib}"
- [ -n "${actual}" ] && f_actual || f_getstatus
+ f_getstatus
}
report() {