Browse Source

adblock: update 4.1.4

* dnsmasq upstream has changed the code for domain handling
  and recommends the 'local' syntax for large blocklists
* remove pipefail command, see #19043 for reference
* removed the unused 'adb_dnsinotify' parameter
* removed the 'adb_maxqueue' parameter,
  the queue size will be automatically set by the number of cpu cores
* various cleanups, mostly shellcheck related

Signed-off-by: Dirk Brenken <dev@brenken.org>
(cherry picked from commit 254b3d9380)
lilik-openwrt-22.03
Dirk Brenken 2 years ago
parent
commit
aaf90f333e
No known key found for this signature in database GPG Key ID: 9D71CD547BFAE684
6 changed files with 642 additions and 1129 deletions
  1. +3
    -3
      net/adblock/Makefile
  2. +15
    -16
      net/adblock/files/README.md
  3. +0
    -1
      net/adblock/files/adblock.conf
  4. +74
    -149
      net/adblock/files/adblock.init
  5. +21
    -30
      net/adblock/files/adblock.mail
  6. +529
    -930
      net/adblock/files/adblock.sh

+ 3
- 3
net/adblock/Makefile View File

@ -6,8 +6,8 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=adblock
PKG_VERSION:=4.1.3
PKG_RELEASE:=9
PKG_VERSION:=4.1.4
PKG_RELEASE:=1
PKG_LICENSE:=GPL-3.0-or-later
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
@ -22,7 +22,7 @@ define Package/adblock
endef
define Package/adblock/description
Powerful adblock script to block ad/abuse domains via dnsmasq, unbound, named or kresd.
Powerful adblock solution to block ad/abuse domains via dnsmasq, unbound, named or kresd.
The script supports many domain blacklist sites plus manual black- and whitelist overrides.
Please see https://github.com/openwrt/packages/blob/master/net/adblock/files/README.md for further information.


+ 15
- 16
net/adblock/files/README.md View File

@ -95,7 +95,7 @@ A lot of people already use adblocker plugins within their desktop browsers, but
* Strong LuCI support, all relevant options are exposed to the web frontend
## Prerequisites
* [OpenWrt](https://openwrt.org), tested with the stable release series (19.07.x) and with the latest rolling snapshot releases. On turris devices it has been successfully tested with TurrisOS 5.1.x
* [OpenWrt](https://openwrt.org), tested with the stable release series and with the latest rolling snapshot releases.
<b>Please note:</b> Older OpenWrt releases like 18.06.x or 17.01.x are _not_ supported!
<b>Please note:</b> Devices with less than 128 MByte RAM are _not_ supported!
* A usual setup with an enabled DNS backend at minimum - dump AP modes without a working DNS backend are _not_ supported
@ -130,7 +130,7 @@ Available commands:
resume Resume adblock processing
query &lt;domain&gt; Query active blocklists and backups for a specific domain
report [&lt;search&gt;] Print DNS statistics with an optional search parameter
list [&lt;add&gt;|&lt;add_sha&gt;|&lt;add_utc&gt;|&lt;add_eng&gt;|&lt;add_stb&gt;|&lt;remove&gt;|&lt;remove_sha&gt;|&lt;remove_utc&gt;|&lt;remove_eng&gt;|&lt;remove_stb&gt;] &lt;source(s)&gt; List/Edit available sources
list [&lt;add&gt;|&lt;add_utc&gt;|&lt;add_eng&gt;|&lt;add_stb&gt;|&lt;remove&gt;|&lt;remove_utc&gt;|&lt;remove_eng&gt;|&lt;remove_stb&gt;] &lt;source(s)&gt; List/Edit available sources
timer [&lt;add&gt; &lt;tasks&gt; &lt;hour&gt; [&lt;minute&gt;] [&lt;weekday&gt;]]|[&lt;remove&gt; &lt;line no.&gt;] List/Edit cron update intervals
version Print version information
running Check if service is running
@ -155,12 +155,10 @@ Available commands:
| adb_debug | 0, disabled | set to 1 to enable the debug output |
| adb_nice | 0, standard prio. | valid nice level range 0-19 of the adblock processes |
| adb_forcedns | 0, disabled | set to 1 to force DNS requests to the local resolver |
| adb_maxqueue | 4 | size of the download queue to handle downloads & list processing in parallel |
| adb_dnsdir | -, auto-detected | path for the generated blocklist file 'adb_list.overall' |
| adb_dnstimeout | 10 | timeout in seconds to wait for a successful DNS backend restart |
| adb_dnsinstance | 0, first instance | set to the relevant dns backend instance used by adblock (dnsmasq only) |
| adb_dnsflush | 0, disabled | set to 1 to flush the DNS Cache before & after adblock processing |
| adb_dnsinotify | -, not set | set to 1 to prevent adblock triggered restarts for DNS backends with autoload functions |
| adb_dnsallow | -, not set | set to 1 to disable selective DNS whitelisting (RPZ-PASSTHRU) |
| adb_lookupdomain | example.com | external domain to check for a successful DNS backend restart or 'false' to disable this check |
| adb_portlist | 53 853 5353 | space separated list of firewall ports which should be redirected locally |
@ -247,21 +245,22 @@ Finally enable E-Mail support and add a valid E-Mail receiver address in LuCI.
**Service status output:**
In LuCI you'll see the realtime status in the 'Runtime' section on the overview page.
To get the status in the CLI, just call _/etc/init.d/adblock status_ or _/etc/init.d/adblock status\_service_ (in 19.07 and TurrisOS):
To get the status in the CLI, just call _/etc/init.d/adblock status_ or _/etc/init.d/adblock status\_service_:
<pre><code>
~# /etc/init.d/adblock status
~#@blackhole:~# /etc/init.d/adblock status
::: adblock runtime information
+ adblock_status : enabled
+ adblock_version : 4.1.0
+ blocked_domains : 32658
+ active_sources : android_tracking, disconnect, shallalist
+ dns_backend : dnsmasq, /tmp/dnsmasq.d
+ run_utils : /usr/bin/curl, /usr/bin/gawk
+ run_ifaces : trigger: trm_wwan, report: br-lan
+ run_directories : base: /tmp, backup: /tmp/adblock-Backup, report: /tmp/adblock-Report, jail: /tmp
+ run_flags : backup: 1, flush: 0, force: 1, search: 1, report: 1, mail: 0, jail: 0
+ last_run : reload, 0m 25s, 252/177/167, 26.02.2021 18:31:41
+ system : GL.iNet GL-MT1300, OpenWrt SNAPSHOT r15875-1bf6d70e60
+ adblock_version : 4.1.4
+ blocked_domains : 268355
+ active_sources : adaway, adguard, adguard_tracking, android_tracking, bitcoin, disconnect, firetv_tracking, games_t
racking, hblock, oisd_basic, phishing_army, smarttv_tracking, stopforumspam, wally3k, winspy, yoyo
+ dns_backend : unbound (unbound-control), /var/lib/unbound
+ run_utils : download: /usr/bin/curl, sort: /usr/libexec/sort-coreutils, awk: /bin/busybox
+ run_ifaces : trigger: wan, report: br-lan
+ run_directories : base: /tmp, backup: /mnt/data/adblock-Backup, report: /mnt/data/adblock-Report, jail: /tmp
+ run_flags : backup: ✔, flush: ✘, force: ✔, search: ✘, report: ✔, mail: ✔, jail: ✘
+ last_run : restart, 3m 17s, 249/73/68, 2022-09-10T13:43:07+02:00
+ system : ASUS RT-AX53U, OpenWrt SNAPSHOT r20535-2ca5602864
</code></pre>
The 'last\_run' line includes the used start type, the run duration, the memory footprint after DNS backend loading (total/free/available) and the date/time of the last run.


+ 0
- 1
net/adblock/files/adblock.conf View File

@ -8,7 +8,6 @@ config adblock 'global'
option adb_mail '0'
option adb_report '0'
option adb_backup '1'
option adb_maxqueue '4'
list adb_sources 'adaway'
list adb_sources 'adguard'
list adb_sources 'disconnect'


+ 74
- 149
net/adblock/files/adblock.init View File

@ -2,14 +2,13 @@
# Copyright (c) 2015-2022 Dirk Brenken (dev@brenken.org)
# This is free software, licensed under the GNU General Public License v3.
# set (s)hellcheck exceptions
# shellcheck disable=1091,2010,2016,2034,2039,2059,2086,2091,2129,2143,2154,2181,2183,2188
# disable (s)hellcheck in release
# shellcheck disable=all
START=30
USE_PROCD=1
if [ -n "$(type -t extra_command)" ]
then
if [ -n "$(type -t extra_command)" ]; then
extra_command "suspend" "Suspend adblock processing"
extra_command "resume" "Resume adblock processing"
extra_command "query" "<domain> Query active blocklists and backups for a specific domain"
@ -33,35 +32,26 @@ adb_init="/etc/init.d/adblock"
adb_script="/usr/bin/adblock.sh"
adb_pidfile="/var/run/adblock.pid"
if [ -s "${adb_pidfile}" ] && { [ "${action}" = "start" ] || [ "${action}" = "stop" ] || \
[ "${action}" = "restart" ] || [ "${action}" = "reload" ] || [ "${action}" = "report" ] || \
[ "${action}" = "suspend" ] || [ "${action}" = "resume" ] || [ "${action}" = "query" ] || \
{ [ "${action}" = "list" ] && [ -n "${1}" ]; }; }
then
if [ -s "${adb_pidfile}" ] && { [ "${action}" = "start" ] || [ "${action}" = "stop" ] ||
[ "${action}" = "restart" ] || [ "${action}" = "reload" ] || [ "${action}" = "report" ] ||
[ "${action}" = "suspend" ] || [ "${action}" = "resume" ] || [ "${action}" = "query" ] ||
{ [ "${action}" = "list" ] && [ -n "${1}" ]; }; }; then
exit 0
fi
version()
{
version() {
rc_procd "${adb_script}" version
}
boot()
{
[ -s "${adb_pidfile}" ] && > "${adb_pidfile}"
boot() {
[ -s "${adb_pidfile}" ] && : >"${adb_pidfile}"
rc_procd start_service
}
start_service()
{
if [ "$("${adb_init}" enabled; printf "%u" ${?})" -eq 0 ]
then
if [ "${action}" = "boot" ]
then
if [ -n "$(uci_get adblock global adb_trigger)" ]
then
return 0
fi
start_service() {
if "${adb_init}" enabled; then
if [ "${action}" = "boot" ]; then
[ -n "$(uci_get adblock global adb_trigger)" ] && return 0
fi
procd_open_instance "adblock"
procd_set_param command "${adb_script}" "${@}"
@ -73,140 +63,99 @@ start_service()
fi
}
reload_service()
{
reload_service() {
rc_procd start_service reload
}
stop_service()
{
stop_service() {
rc_procd "${adb_script}" stop
}
restart()
{
restart() {
rc_procd start_service restart
}
suspend()
{
suspend() {
rc_procd start_service suspend
}
resume()
{
resume() {
rc_procd start_service resume
}
query()
{
query() {
rc_procd "${adb_script}" query "${1}"
}
report()
{
report() {
rc_procd "${adb_script}" report "${1:-"cli"}" "${2}" "${3}"
}
list()
{
local src_archive src_file src_enabled enabled name sha_list utc_list action="${1}"
list() {
local src_archive src_file src_enabled enabled name utc_list size focus descurl action="${1}"
if [ "${action%_*}" = "add" ] || [ "${action%_*}" = "remove" ]
then
if [ "${action%_*}" = "add" ] || [ "${action%_*}" = "remove" ]; then
shift
for name in "${@}"
do
for name in "${@}"; do
case "${action}" in
"add")
if [ -z "$(uci_get adblock global adb_sources | grep -Fo "${name}")" ]
then
if ! uci_get adblock global adb_sources | grep -q "${name}"; then
uci_add_list adblock global adb_sources "${name}"
printf "%s\n" "::: adblock source '${name}' added to config"
fi
;;
;;
"remove")
if [ -n "$(uci_get adblock global adb_sources | grep -Fo "${name}")" ]
then
if uci_get adblock global adb_sources | grep -q "${name}"; then
uci_remove_list adblock global adb_sources "${name}"
printf "%s\n" "::: adblock source '${name}' removed from config"
fi
;;
"add_sha")
if [ -z "$(uci_get adblock global adb_sha_sources | grep -Fo "${name}")" ]
then
uci_add_list adblock global adb_sha_sources "${name}"
printf "%s\n" "::: adblock shallalist '${name}' added to config"
fi
;;
"remove_sha")
if [ -n "$(uci_get adblock global adb_sha_sources | grep -Fo "${name}")" ]
then
uci_remove_list adblock global adb_sha_sources "${name}"
printf "%s\n" "::: adblock shallalist '${name}' removed from config"
fi
;;
;;
"add_utc")
if [ -z "$(uci_get adblock global adb_utc_sources | grep -Fo "${name}")" ]
then
if ! uci_get adblock global adb_utc_sources | grep -q "${name}"; then
uci_add_list adblock global adb_utc_sources "${name}"
printf "%s\n" "::: adblock utcapitole '${name}' added to config"
fi
;;
;;
"remove_utc")
if [ -n "$(uci_get adblock global adb_utc_sources | grep -Fo "${name}")" ]
then
if uci_get adblock global adb_utc_sources | grep -q "${name}"; then
uci_remove_list adblock global adb_utc_sources "${name}"
printf "%s\n" "::: adblock utcapitole '${name}' removed from config"
fi
;;
;;
"add_eng")
if [ -z "$(uci_get adblock global adb_eng_sources | grep -Fo "${name}")" ]
then
if ! uci_get adblock global adb_eng_sources | grep -q "${name}"; then
uci_add_list adblock global adb_eng_sources "${name}"
printf "%s\n" "::: adblock energized '${name}' added to config"
fi
;;
;;
"remove_eng")
if [ -n "$(uci_get adblock global adb_eng_sources | grep -Fo "${name}")" ]
then
if uci_get adblock global adb_eng_sources | grep -q "${name}"; then
uci_remove_list adblock global adb_eng_sources "${name}"
printf "%s\n" "::: adblock energized '${name}' removed from config"
fi
;;
;;
"add_stb")
if [ -z "$(uci_get adblock global adb_stb_sources | grep -Fo "${name}")" ]
then
if ! uci_get adblock global adb_stb_sources | grep -q "${name}"; then
uci_add_list adblock global adb_stb_sources "${name}"
printf "%s\n" "::: adblock stevenblack '${name}' added to config"
fi
;;
;;
"remove_stb")
if [ -n "$(uci_get adblock global adb_stb_sources | grep -Fo "${name}")" ]
then
if uci_get adblock global adb_stb_sources | grep -q "${name}"; then
uci_remove_list adblock global adb_stb_sources "${name}"
printf "%s\n" "::: adblock stevenblack '${name}' removed from config"
fi
;;
;;
esac
done
if [ -n "$(uci -q changes adblock)" ]
then
uci_commit adblock
"${adb_init}" start
fi
[ -n "$(uci -q changes adblock)" ] && { uci_commit adblock; "${adb_init}" start; }
else
src_archive="$(uci_get adblock global adb_srcarc "/etc/adblock/adblock.sources.gz")"
src_file="$(uci_get adblock global adb_srcfile "/tmp/adb_sources.json")"
src_enabled="$(uci -q show adblock.global.adb_sources)"
if [ -r "${src_archive}" ]
then
zcat "${src_archive}" > "${src_file}"
else
printf "%s\n" "::: adblock source archive '${src_archive}' not found"
fi
if [ -r "${src_file}" ]
then
[ -r "${src_archive}" ] && zcat "${src_archive}" >"${src_file}" || printf "%s\n" "::: adblock source archive '${src_archive}' not found"
if [ -r "${src_file}" ]; then
src_enabled="${src_enabled#*=}"
src_enabled="${src_enabled//\'}"
printf "%s\n" "::: Available adblock sources"
@ -215,18 +164,15 @@ list()
printf "%s\n" " -------------------------------------------------------------------"
json_load_file "${src_file}"
json_get_keys keylist
for key in ${keylist}
do
for key in ${keylist}; do
json_select "${key}"
json_get_var size "size"
json_get_var focus "focus"
json_get_var descurl "descurl"
json_get_var url "url"
json_get_var rule "rule"
if [ -n "${url}" ] && [ -n "${rule}" ]
then
if [ -n "$(printf "%s" "${src_enabled}" | grep -Fo "${key}")" ]
then
if [ -n "${url}" ] && [ -n "${rule}" ]; then
if printf "%s" "${src_enabled}" | grep -q "${key}"; then
enabled="x"
else
enabled=" "
@ -238,23 +184,19 @@ list()
fi
json_select ..
done
sha_list="$(uci_get adblock global adb_sha_sources "-")"
utc_list="$(uci_get adblock global adb_utc_sources "-")"
eng_list="$(uci_get adblock global adb_eng_sources "-")"
stb_list="$(uci_get adblock global adb_stb_sources "-")"
printf "%s\n" " ---------------------------------------------------------------------------"
printf " * %s\n" "Configured shallalist categories: ${sha_list// /, }"
printf " * %s\n" "Configured utcapitole categories: ${utc_list// /, }"
printf " * %s\n" "Configured energized variants: ${eng_list// /, }"
printf " * %s\n" "Configured stevenblack variants: ${stb_list// /, }"
if [ -n "${src_enabled// }" ]
then
if [ -n "${src_enabled// }" ]; then
printf "%s\n" " ---------------------------------------------------------------------------"
printf "%s\n" " Sources without valid configuration"
printf "%s\n" " Sources with invalid configuration"
printf "%s\n" " ---------------------------------------------------------------------------"
for key in ${src_enabled}
do
for key in ${src_enabled}; do
printf " - %s\n" "${key:0:20}"
done
fi
@ -264,41 +206,34 @@ list()
fi
}
status()
{
status() {
status_service
}
status_service()
{
local key keylist value idxval values rtfile
status_service() {
local key keylist value idxval values type rtfile
rtfile="$(uci_get adblock global adb_rtfile "/tmp/adb_runtime.json")"
json_load_file "${rtfile}" >/dev/null 2>&1
json_get_keys keylist
if [ -n "${keylist}" ]
then
if [ -n "${keylist}" ]; then
printf "%s\n" "::: adblock runtime information"
for key in ${keylist}
do
for key in ${keylist}; do
json_get_var value "${key}" >/dev/null 2>&1
if [ "${key%_*}" = "active" ]
then
if [ "${key%_*}" = "active" ]; then
printf " + %-15s : " "${key}"
json_select "${key}" >/dev/null 2>&1
values=""
index=1
while json_get_type type "${index}" && [ "${type}" = "object" ]
do
index="1"
while json_get_type type "${index}" && [ "${type}" = "object" ]; do
json_get_values idxval "${index}" >/dev/null 2>&1
if [ "${index}" = "1" ]
then
if [ "${index}" = "1" ]; then
values="${idxval}"
else
values="${values}, ${idxval}"
fi
index=$((index+1))
index="$((index + 1))"
done
values="$(printf "%s" "${values}" | awk '{NR=1;max=98;if(length($0)>max+1)while($0){if(NR==1){print substr($0,1,max)}else{printf"%-22s%s\n","",substr($0,1,max)}{$0=substr($0,max+1);NR=NR+1}}else print}')"
printf "%s\n" "${values:-"-"}"
@ -312,50 +247,40 @@ status_service()
fi
}
timer()
{
timer() {
local cron_file cron_content cron_lineno action="${1:-"list"}" cron_tasks="${2}" hour="${3}" minute="${4:-0}" weekday="${5:-"*"}"
cron_file="/etc/crontabs/root"
if [ -s "${cron_file}" ] && [ "${action}" = "list" ]
then
if [ -s "${cron_file}" ] && [ "${action}" = "list" ]; then
awk '{print NR "> " $0}' "${cron_file}"
elif [ "${action}" = "add" ]
then
elif [ -x "/etc/init.d/cron" ] && [ "${action}" = "add" ]; then
hour="${hour//[[:alpha:]]/}"
minute="${minute//[[:alpha:]]/}"
if [ -n "${cron_tasks}" ] && [ -n "${hour}" ] && [ -n "${minute}" ] && [ -n "${weekday}" ] && \
[ "${hour}" -ge 0 ] && [ "${hour}" -le 23 ] && \
[ "${minute}" -ge 0 ] && [ "${minute}" -le 59 ]
then
printf "%02d %02d %s\n" "${minute}" "${hour}" "* * ${weekday} ${adb_init} ${cron_tasks}" >> "${cron_file}"
if [ -n "${cron_tasks}" ] && [ -n "${hour}" ] && [ -n "${minute}" ] && [ -n "${weekday}" ] &&
[ "${hour}" -ge 0 ] && [ "${hour}" -le 23 ] &&
[ "${minute}" -ge 0 ] && [ "${minute}" -le 59 ]; then
printf "%02d %02d %s\n" "${minute}" "${hour}" "* * ${weekday} ${adb_init} ${cron_tasks}" >>"${cron_file}"
/etc/init.d/cron restart
fi
elif [ -s "${cron_file}" ] && [ "${action}" = "remove" ]
then
elif [ -x "/etc/init.d/cron" ] && [ -s "${cron_file}" ] && [ "${action}" = "remove" ]; then
cron_tasks="${cron_tasks//[[:alpha:]]/}"
cron_lineno="$(awk 'END{print NR}' "${cron_file}")"
cron_content="$(awk '{print $0}' "${cron_file}")"
if [ "${cron_tasks:-"0"}" -le "${cron_lineno:-"1"}" ] && [ -n "${cron_content}" ]
then
printf "%s\n" "${cron_content}" | awk "NR!~/^${cron_tasks}$/" > "${cron_file}"
if [ "${cron_tasks:-"0"}" -le "${cron_lineno:-"1"}" ] && [ -n "${cron_content}" ]; then
printf "%s\n" "${cron_content}" | awk "NR!~/^${cron_tasks}$/" >"${cron_file}"
/etc/init.d/cron restart
fi
fi
}
service_triggers()
{
service_triggers() {
local iface delay
iface="$(uci_get adblock global adb_trigger)"
delay="$(uci_get adblock global adb_triggerdelay "5")"
PROCD_RELOAD_DELAY=$((delay*1000))
PROCD_RELOAD_DELAY="$((delay * 1000))"
if [ -n "${iface}" ]
then
procd_add_interface_trigger "interface.*.up" "${iface}" "${adb_init}" "start"
fi
[ -n "${iface}" ] && procd_add_interface_trigger "interface.*.up" "${iface}" "${adb_init}" "start"
procd_add_reload_trigger "adblock"
}

+ 21
- 30
net/adblock/files/adblock.mail View File

@ -1,63 +1,56 @@
#!/bin/sh
# send mail script for adblock notifications
# Copyright (c) 2015-2021 Dirk Brenken (dev@brenken.org)
# Copyright (c) 2015-2022 Dirk Brenken (dev@brenken.org)
# This is free software, licensed under the GNU General Public License v3.
# Please note: you have to manually install and configure the package 'msmtp' before using this script
# set (s)hellcheck exceptions
# shellcheck disable=1091,2010,2016,2034,2039,2059,2086,2091,2129,2143,2154,2181,2183,2188
# shellcheck disable=all
LC_ALL=C
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
if [ -r "/lib/functions.sh" ]
then
. "/lib/functions.sh"
adb_debug="$(uci_get adblock global adb_debug "0")"
adb_mailsender="$(uci_get adblock global adb_mailsender "no-reply@adblock")"
adb_mailreceiver="$(uci_get adblock global adb_mailreceiver)"
adb_mailtopic="$(uci_get adblock global adb_mailtopic "adblock notification")"
adb_mailprofile="$(uci_get adblock global adb_mailprofile "adb_notify")"
fi
[ -r "/lib/functions.sh" ] && . "/lib/functions.sh"
adb_debug="$(uci_get adblock global adb_debug "0")"
adb_mailsender="$(uci_get adblock global adb_mailsender "no-reply@adblock")"
adb_mailreceiver="$(uci_get adblock global adb_mailreceiver)"
adb_mailtopic="$(uci_get adblock global adb_mailtopic "adblock notification")"
adb_mailprofile="$(uci_get adblock global adb_mailprofile "adb_notify")"
adb_ver="${1}"
adb_mail="$(command -v msmtp)"
adb_logger="$(command -v logger)"
adb_logread="$(command -v logread)"
adb_rc=1
adb_rc="1"
f_log()
{
f_log() {
local class="${1}" log_msg="${2}"
if [ -x "${adb_logger}" ]
then
if [ -x "${adb_logger}" ]; then
"${adb_logger}" -p "${class}" -t "adblock-${adb_ver}[${$}]" "${log_msg}"
else
printf "%s %s %s\n" "${class}" "adblock-${adb_ver}[${$}]" "${log_msg}"
fi
}
if [ -z "${adb_mailreceiver}" ]
then
if [ -z "${adb_mailreceiver}" ]; then
f_log "err" "please set the mail receiver with the 'adb_mailreceiver' option"
exit ${adb_rc}
fi
if [ "${adb_debug}" = "1" ]
then
debug="--debug"
fi
[ "${adb_debug}" = "1" ] && debug="--debug"
adb_mailhead="From: ${adb_mailsender}\nTo: ${adb_mailreceiver}\nSubject: ${adb_mailtopic}\nReply-to: ${adb_mailsender}\nMime-Version: 1.0\nContent-Type: text/html;charset=utf-8\nContent-Disposition: inline\n\n"
# info preparation
#
sys_info="$(strings /etc/banner 2>/dev/null; ubus call system board | sed -e 's/\"release\": {//' | sed -e 's/^[ \t]*//' | sed -e 's/[{}\",]//g' | sed -e 's/[ ]/ \t/' | sed '/^$/d' 2>/dev/null)"
sys_info="$(
strings /etc/banner 2>/dev/null
ubus call system board | sed -e 's/\"release\": {//' | sed -e 's/^[ \t]*//' | sed -e 's/[{}\",]//g' | sed -e 's/[ ]/ \t/' | sed '/^$/d' 2>/dev/null
)"
adb_info="$(/etc/init.d/adblock status 2>/dev/null)"
rep_info="${2}"
if [ -x "${adb_logread}" ]
then
if [ -x "${adb_logread}" ]; then
log_info="$("${adb_logread}" -l 100 -e "adblock-" | awk '{NR=1;max=120;if(length($0)>max+1)while($0){if(NR==1){print substr($0,1,max)}else{print substr($0,1,max)}{$0=substr($0,max+1);NR=NR+1}}else print}')"
fi
@ -66,8 +59,7 @@ fi
adb_mailtext="<html><body><pre style='display:block;font-family:monospace;font-size:1rem;padding:20;background-color:#f3eee5;white-space:pre'>"
adb_mailtext="${adb_mailtext}\n<strong>++\n++ System Information ++\n++</strong>\n${sys_info}"
adb_mailtext="${adb_mailtext}\n\n<strong>++\n++ Adblock Information ++\n++</strong>\n${adb_info}"
if [ -n "${rep_info}" ]
then
if [ -n "${rep_info}" ]; then
adb_mailtext="${adb_mailtext}\n\n<strong>++\n++ Report Information ++\n++</strong>\n${rep_info}"
fi
adb_mailtext="${adb_mailtext}\n\n<strong>++\n++ Logfile Information ++\n++</strong>\n${log_info}"
@ -75,8 +67,7 @@ adb_mailtext="${adb_mailtext}</pre></body></html>"
# send mail
#
if [ -x "${adb_mail}" ]
then
if [ -x "${adb_mail}" ]; then
printf "%b" "${adb_mailhead}${adb_mailtext}" 2>/dev/null | "${adb_mail}" ${debug} -a "${adb_mailprofile}" "${adb_mailreceiver}" >/dev/null 2>&1
adb_rc=${?}
f_log "info" "mail sent to '${adb_mailreceiver}' with rc '${adb_rc}'"


+ 529
- 930
net/adblock/files/adblock.sh
File diff suppressed because it is too large
View File


Loading…
Cancel
Save