From: Dirk Brenken Date: Mon, 17 Feb 2025 20:58:24 +0000 (+0100) Subject: adblock: release 4.2.5-1 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=162b1e693e68b44500d301e3db0ce2dc19db7336;p=feed%2Fpackages.git adblock: release 4.2.5-1 * removed needless subshell calls * add memory measurements: - size of the final blocklist in MB - free memory in MB (MemAvailable from /proc/meminfo) - script max. used RAM (VmHWM from /proc/$$/status) * optimized restart logic * cosmetics Signed-off-by: Dirk Brenken --- diff --git a/net/adblock/Makefile b/net/adblock/Makefile index a84b8eeb88..36d7fd7fa1 100644 --- a/net/adblock/Makefile +++ b/net/adblock/Makefile @@ -6,8 +6,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=adblock -PKG_VERSION:=4.2.4 -PKG_RELEASE:=2 +PKG_VERSION:=4.2.5 +PKG_RELEASE:=1 PKG_LICENSE:=GPL-3.0-or-later PKG_MAINTAINER:=Dirk Brenken diff --git a/net/adblock/files/README.md b/net/adblock/files/README.md index 7fa2dc21bc..7f99e7108b 100644 --- a/net/adblock/files/README.md +++ b/net/adblock/files/README.md @@ -156,7 +156,7 @@ Available commands: | adb_enabled | 1, enabled | set to 0 to disable the adblock service | | adb_srcarc | -, /etc/adblock/adblock.sources.gz | full path to the used adblock source archive | | adb_srcfile | -, /tmp/adb_sources.json | full path to the used adblock source file, which has a higher precedence than the archive file | -| adb_dns | -, auto-detected | 'dnsmasq', 'unbound', 'named', 'kresd' or 'raw' | +| adb_dns | -, auto-detected | 'dnsmasq', 'unbound', 'named', 'kresd', 'smartdns' or 'raw' | | adb_fetchutil | -, auto-detected | 'uclient-fetch', 'wget', 'curl' or 'aria2c' | | adb_fetchparm | -, auto-detected | manually override the config options for the selected download utility | | adb_fetchinsecure | 0, disabled | don't check SSL server certificates during download | diff --git a/net/adblock/files/adblock.init b/net/adblock/files/adblock.init index d35b3c1e7c..d1b699c04c 100755 --- a/net/adblock/files/adblock.init +++ b/net/adblock/files/adblock.init @@ -51,6 +51,7 @@ stop_service() { } restart() { + rc_procd "${adb_script}" stop rc_procd start_service restart } diff --git a/net/adblock/files/adblock.mail b/net/adblock/files/adblock.mail index f5f74d57b6..a5132aaccb 100755 --- a/net/adblock/files/adblock.mail +++ b/net/adblock/files/adblock.mail @@ -1,6 +1,6 @@ #!/bin/sh # send mail script for adblock notifications -# Copyright (c) 2015-2024 Dirk Brenken (dev@brenken.org) +# Copyright (c) 2015-2025 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 diff --git a/net/adblock/files/adblock.sh b/net/adblock/files/adblock.sh index bcce5667b1..0166b09b18 100755 --- a/net/adblock/files/adblock.sh +++ b/net/adblock/files/adblock.sh @@ -27,6 +27,7 @@ adb_mailcnt="0" adb_jail="0" adb_tld="1" adb_dns="" +adb_dnspid="" adb_dnsprefix="adb_list" adb_locallist="blacklist whitelist iplist" adb_tmpbase="/tmp" @@ -82,7 +83,8 @@ f_load() { adb_packages="$("${adb_ubuscmd}" -S call rpc-sys packagelist '{ "all": true }' 2>/dev/null)" adb_ver="$(printf "%s" "${adb_packages}" | "${adb_jsoncmd}" -ql1 -e '@.packages.adblock')" - adb_sysver="$("${adb_ubuscmd}" -S call system board 2>/dev/null | "${adb_jsoncmd}" -ql1 -e '@.model' -e '@.release.target' -e '@.release.distribution' -e '@.release.version' -e '@.release.revision' | + adb_sysver="$("${adb_ubuscmd}" -S call system board 2>/dev/null | + "${adb_jsoncmd}" -ql1 -e '@.model' -e '@.release.target' -e '@.release.distribution' -e '@.release.version' -e '@.release.revision' | "${adb_awkcmd}" 'BEGIN{RS="";FS="\n"}{printf "%s, %s, %s %s %s %s",$1,$2,$3,$4,$5,$6}')" f_conf @@ -113,7 +115,7 @@ f_load() { f_log "info" "Please install the package 'tcpdump' or 'tcpdump-mini' to use the reporting feature" elif [ -x "${adb_dumpcmd}" ]; then bg_pid="$("${adb_pgrepcmd}" -f "^${adb_dumpcmd}.*adb_report\\.pcap$" | "${adb_awkcmd}" '{ORS=" "; print $1}')" - if [ "${adb_report}" = "0" ] || { [ -n "${bg_pid}" ] && { [ "${adb_action}" = "stop" ] || [ "${adb_action}" = "restart" ]; }; }; then + if [ "${adb_report}" = "0" ] || { [ -n "${bg_pid}" ] && [ "${adb_action}" = "stop" ]; }; then if [ -n "${bg_pid}" ]; then kill -HUP "${bg_pid}" 2>/dev/null while kill -0 "${bg_pid}" 2>/dev/null; do @@ -445,16 +447,16 @@ f_temp() { f_rmtemp() { rm -rf "${adb_tmpdir}" "${adb_srcfile}" : >"${adb_pidfile}" + if [ "${adb_backup}" = "0" ]; then + rm -f "${adb_backupdir}/${adb_dnsprefix}".*.gz + fi } # remove dns related files # f_rmdns() { - if "${adb_ubuscmd}" -S call service list '{"name":"adblock"}' | "${adb_jsoncmd}" -ql1 -e '@["adblock"].instances.*.running' >/dev/null; then + if "${adb_ubuscmd}" -S call service list 2>/dev/null | "${adb_jsoncmd}" -ql1 -e '@["adblock"].instances.*.running' >/dev/null; then : >"${adb_rtfile}" - if [ "${adb_backup}" = "0" ] || [ "${adb_action}" = "stop" ]; then - rm -f "${adb_backupdir}/${adb_dnsprefix}".*.gz - fi printf "%b" "${adb_dnsheader}" >"${adb_dnsdir}/${adb_dnsfile}" f_dnsup 4 fi @@ -589,7 +591,7 @@ f_extconf() { # restart dns backend # f_dnsup() { - local rset dns_service dns_up dns_pid restart_rc cnt="0" out_rc="4" in_rc="${1:-0}" + local rset dns_service dns_up restart_rc cnt="0" out_rc="4" in_rc="${1:-0}" if [ "${adb_dns}" = "raw" ] || [ -z "${adb_dns}" ]; then out_rc="0" @@ -624,21 +626,21 @@ f_dnsup() { restart_rc="${?}" fi fi - if [ "${restart_rc}" = "0" ]; then + if [ "${restart_rc}" = "0" ] && [ "${in_rc}" = "0" ]; then rset="/^(([[:alnum:]_-]{1,63}\\.)+[[:alnum:]-]+|[[:alnum:]-]+)([[:space:]]|$)/{print tolower(\$1)}" while [ "${cnt}" -le "${adb_dnstimeout}" ]; do - dns_service="$("${adb_ubuscmd}" -S call service list "{\"name\":\"${adb_dns}\"}")" + dns_service="$("${adb_ubuscmd}" -S call service list 2>/dev/null)" dns_up="$(printf "%s" "${dns_service}" | "${adb_jsoncmd}" -l1 -e "@[\"${adb_dns}\"].instances.*.running")" - dns_pid="$(printf "%s" "${dns_service}" | "${adb_jsoncmd}" -l1 -e "@[\"${adb_dns}\"].instances.*.pid")" - if [ "${dns_up}" = "true" ] && [ -n "${dns_pid}" ] && ! ls "/proc/${dns_pid}/fd/${adb_dnsdir}/${adb_dnsfile}" >/dev/null 2>&1; then + adb_dnspid="$(printf "%s" "${dns_service}" | "${adb_jsoncmd}" -l1 -e "@[\"${adb_dns}\"].instances.*.pid")" + if [ "${dns_up}" = "true" ] && [ -n "${adb_dnspid}" ] && ! ls "/proc/${adb_dnspid}/fd/${adb_dnsdir}/${adb_dnsfile}" >/dev/null 2>&1; then if [ -x "${adb_lookupcmd}" ] && [ "${adb_lookupdomain}" != "false" ] && [ -n "$(printf "%s" "${adb_lookupdomain}" | "${adb_awkcmd}" "${rset}")" ]; then if "${adb_lookupcmd}" "${adb_lookupdomain}" >/dev/null 2>&1; then out_rc="0" break fi else - sleep ${adb_dnstimeout} - cnt=${adb_dnstimeout} + sleep "${adb_dnstimeout}" + cnt="${adb_dnstimeout}" out_rc="0" break fi @@ -654,14 +656,14 @@ f_dnsup() { fi fi - f_log "debug" "f_dnsup ::: dns: ${adb_dns}, cache_cmd: ${adb_dnscachecmd:-"-"}, lookup_cmd: ${adb_lookupcmd:-"-"}, lookup_domain: ${adb_lookupdomain:-"-"}, restart_rc: ${restart_rc:-"-"}, dns_flush: ${adb_dnsflush}, dns_timeout: ${adb_dnstimeout}, dns_cnt: ${cnt}, in_rc: ${in_rc}, out_rc: ${out_rc}" + f_log "debug" "f_dnsup ::: dns: ${adb_dns}, cache_cmd: ${adb_dnscachecmd:-"-"}, lookup_cmd: ${adb_lookupcmd:-"-"}, lookup_domain: ${adb_lookupdomain:-"-"}, restart_rc: ${restart_rc:-"-"}, dns_flush: ${adb_dnsflush}, dns_timeout: ${adb_dnstimeout}, dns_pid: ${adb_dnspid}, dns_cnt: ${cnt}, in_rc: ${in_rc}, out_rc: ${out_rc}" return "${out_rc}" } # backup/restore/remove blocklists # f_list() { - local hold file rset item array safe_url safe_ips safe_cname safe_domains ip out_rc file_name cnt mode="${1}" src_name="${2:-"${src_name}"}" in_rc="${src_rc:-0}" use_cname="0" ffiles="-maxdepth 1 -name ${adb_dnsprefix}.*.gz" + local file rset item array safe_url safe_ips safe_cname safe_domains ip out_rc file_name mode="${1}" src_name="${2:-"${src_name}"}" in_rc="${src_rc:-0}" use_cname="0" ffiles="-maxdepth 1 -name ${adb_dnsprefix}.*.gz" case "${mode}" in "iplist") @@ -690,39 +692,41 @@ f_list() { ;; "blacklist" | "whitelist") src_name="${mode}" - if [ "${src_name}" = "blacklist" ] && [ -f "${adb_blacklist}" ]; then - file_name="${adb_tmpfile}.${src_name}" - rset="/^(([[:alnum:]_-]{1,63}\\.)+[[:alnum:]-]+|[[:alnum:]-]+)([[:space:]]|$)/{print tolower(\$1)}" - "${adb_awkcmd}" "${rset}" "${adb_blacklist}" >"${adb_tmpdir}/tmp.raw.${src_name}" - if [ -s "${adb_whitelist}" ]; then - "${adb_awkcmd}" 'NR==FNR{member[$1];next}!($1 in member)' "${adb_whitelist}" "${adb_tmpdir}/tmp.raw.${src_name}" >"${adb_tmpdir}/tmp.deduplicate.${src_name}" - else - "${adb_catcmd}" "${adb_tmpdir}/tmp.raw.${src_name}" >"${adb_tmpdir}/tmp.deduplicate.${src_name}" - fi - "${adb_awkcmd}" 'BEGIN{FS="."}{for(f=NF;f>1;f--)printf "%s.",$f;print $1}' "${adb_tmpdir}/tmp.deduplicate.${src_name}" >"${adb_tmpdir}/tmp.raw.${src_name}" - "${adb_sortcmd}" ${adb_srtopts} -u "${adb_tmpdir}/tmp.raw.${src_name}" 2>/dev/null >"${file_name}" - out_rc="${?}" - elif [ "${src_name}" = "whitelist" ] && [ -f "${adb_whitelist}" ]; then - file_name="${adb_tmpdir}/tmp.raw.${src_name}" - [ "${adb_lookupdomain}" != "false" ] && printf "%s\n" "${adb_lookupdomain}" | "${adb_awkcmd}" "${rset}" >"${file_name}" - rset="/^(([[:alnum:]_-]{1,63}\\.)+[[:alnum:]-]+|[[:alnum:]-]+)([[:space:]]|$)/{print tolower(\$1)}" - "${adb_awkcmd}" "${rset}" "${adb_whitelist}" >>"${file_name}" - out_rc="${?}" - if [ "${out_rc}" = "0" ]; then - "${adb_awkcmd}" "${rset}" "${adb_tmpdir}/tmp.raw.${src_name}" >"${adb_tmpdir}/tmp.rem.${src_name}" - out_rc="${?}" - if [ "${out_rc}" = "0" ] && [ "${adb_dnsallow}" != "1" ]; then - eval "${adb_dnsallow}" "${adb_tmpdir}/tmp.raw.${src_name}" >"${adb_tmpdir}/tmp.add.${src_name}" + rset="/^(([[:alnum:]_-]{1,63}\\.)+[[:alnum:]-]+|[[:alnum:]-]+)([[:space:]]|$)/{print tolower(\$1)}" + case "${src_name}" in + "blacklist") + if [ -f "${adb_blacklist}" ]; then + file_name="${adb_tmpfile}.${src_name}" + "${adb_awkcmd}" "${rset}" "${adb_blacklist}" >"${adb_tmpdir}/tmp.raw.${src_name}" + if [ -s "${adb_whitelist}" ]; then + "${adb_awkcmd}" 'NR==FNR{member[$1];next}!($1 in member)' "${adb_whitelist}" "${adb_tmpdir}/tmp.raw.${src_name}" >"${adb_tmpdir}/tmp.deduplicate.${src_name}" + else + "${adb_catcmd}" "${adb_tmpdir}/tmp.raw.${src_name}" >"${adb_tmpdir}/tmp.deduplicate.${src_name}" + fi + "${adb_awkcmd}" 'BEGIN{FS="."}{for(f=NF;f>1;f--)printf "%s.",$f;print $1}' "${adb_tmpdir}/tmp.deduplicate.${src_name}" >"${adb_tmpdir}/tmp.raw.${src_name}" + "${adb_sortcmd}" ${adb_srtopts} -u "${adb_tmpdir}/tmp.raw.${src_name}" 2>/dev/null >"${file_name}" + out_rc="${?}" + fi + ;; + "whitelist") + if [ -f "${adb_whitelist}" ]; then + file_name="${adb_tmpdir}/tmp.raw.${src_name}" + [ "${adb_lookupdomain}" != "false" ] && printf "%s\n" "${adb_lookupdomain}" | "${adb_awkcmd}" "${rset}" >"${file_name}" + "${adb_awkcmd}" "${rset}" "${adb_whitelist}" >>"${file_name}" + "${adb_awkcmd}" "${rset}" "${adb_tmpdir}/tmp.raw.${src_name}" >"${adb_tmpdir}/tmp.rem.${src_name}" out_rc="${?}" - if [ "${out_rc}" = "0" ] && [ "${adb_jail}" = "1" ] && [ "${adb_dnsstop}" != "0" ]; then - rm -f "${adb_jaildir}/${adb_dnsjail}" - [ -n "${adb_dnsheader}" ] && printf "%b" "${adb_dnsheader}" >>"${adb_jaildir}/${adb_dnsjail}" - "${adb_catcmd}" "${adb_tmpdir}/tmp.add.${src_name}" >>"${adb_jaildir}/${adb_dnsjail}" - printf "%b\n" "${adb_dnsstop}" >>"${adb_jaildir}/${adb_dnsjail}" + if [ "${adb_dnsallow}" != "1" ]; then + eval "${adb_dnsallow}" "${adb_tmpdir}/tmp.raw.${src_name}" >"${adb_tmpdir}/tmp.add.${src_name}" + if [ "${adb_jail}" = "1" ] && [ "${adb_dnsstop}" != "0" ]; then + rm -f "${adb_jaildir}/${adb_dnsjail}" + [ -n "${adb_dnsheader}" ] && printf "%b" "${adb_dnsheader}" >>"${adb_jaildir}/${adb_dnsjail}" + "${adb_catcmd}" "${adb_tmpdir}/tmp.add.${src_name}" >>"${adb_jaildir}/${adb_dnsjail}" + printf "%b\n" "${adb_dnsstop}" >>"${adb_jaildir}/${adb_dnsjail}" + fi fi fi - fi - fi + ;; + esac ;; "safesearch") file_name="${adb_tmpdir}/tmp.safesearch.${src_name}" @@ -804,25 +808,19 @@ f_list() { "${adb_zcatcmd}" "${adb_backupdir}/${adb_dnsprefix}.${src_name}.gz" >"${src_tmpfile}" out_rc="${?}" elif [ -z "${src_name}" ]; then - cnt="1" for file in "${adb_backupdir}/${adb_dnsprefix}".*.gz; do if [ -r "${file}" ]; then name="${file##*/}" name="${name%.*}" - "${adb_zcatcmd}" "${file}" >"${adb_tmpfile}.${name}" & - hold="$((cnt % adb_cores))" - if [ "${hold}" = "0" ]; then - wait - fi - cnt="$((cnt + 1))" + "${adb_zcatcmd}" "${file}" >"${adb_tmpfile}.${name}" + out_rc="${?}" + [ "${out_rc}" != "0" ] && break fi done - wait - out_rc="${?}" else out_rc=4 fi - if [ "${adb_action}" != "start" ] && [ "${adb_action}" != "resume" ] && [ -n "${src_name}" ] && [ "${out_rc}" != "0" ]; then + if [ "${adb_action}" != "start" ] && [ "${adb_action}" != "restart" ] && [ "${adb_action}" != "resume" ] && [ -n "${src_name}" ] && [ "${out_rc}" != "0" ]; then adb_sources="${adb_sources/${src_name}}" fi ;; @@ -854,13 +852,13 @@ f_list() { [ -n "${adb_dnsheader}" ] && printf "%b" "${adb_dnsheader}" >>"${file_name}" [ -s "${adb_tmpdir}/tmp.add.iplist" ] && "${adb_catcmd}" "${adb_tmpdir}/tmp.add.iplist" >>"${file_name}" [ -s "${adb_tmpdir}/tmp.add.whitelist" ] && "${adb_catcmd}" "${adb_tmpdir}/tmp.add.whitelist" >>"${file_name}" - "${adb_catcmd}" "${adb_tmpdir}/tmp.safesearch".* 2>/dev/null >>"${file_name}" + [ "${adb_safesearch}" = "1" ] && "${adb_catcmd}" "${adb_tmpdir}/tmp.safesearch."* 2>/dev/null >>"${file_name}" if [ "${adb_dnsdeny}" != "0" ]; then eval "${adb_dnsdeny}" "${adb_tmpdir}/${adb_dnsfile}" >>"${file_name}" else "${adb_catcmd}" "${adb_tmpdir}/${adb_dnsfile}" >>"${file_name}" fi - out_rc="${?}" + out_rc="0" ;; esac [ "${adb_debug}" = "1" ] || [ "${mode}" = "final" ] && f_count "${mode}" "${file_name}" @@ -873,7 +871,7 @@ f_list() { # top level domain compression # f_tld() { - local cnt cnt_tld cnt_rem source="${1}" temp_tld="${1}.tld" + local cnt_tld cnt_rem source="${1}" temp_tld="${1}.tld" if "${adb_awkcmd}" '{if(NR==1){tld=$NF};while(getline){if(index($NF,tld".")==0){print tld;tld=$NF}}print tld}' "${source}" | "${adb_awkcmd}" 'BEGIN{FS="."}{for(f=NF;f>1;f--)printf "%s.",$f;print $1}' >"${temp_tld}"; then @@ -1002,18 +1000,26 @@ f_query() { # update runtime information # f_jsnup() { - local object sources runtime utils mem_free mem_max status="${1:-"enabled"}" + local pids object sources runtime utils mem_dns mem_free mem_max status="${1:-"enabled"}" - mem_free="$("${adb_awkcmd}" '/^MemAvailable/{printf "%s",int($2/1024)}' "/proc/meminfo" 2>/dev/null)" - mem_max="$("${adb_awkcmd}" '/^VmHWM/{printf "%s",int($2)}' /proc/${$}/status 2>/dev/null)" + if [ -n "${adb_dnspid}" ]; then + pids="$("${adb_pgrepcmd}" -P "${adb_dnspid}" 2>/dev/null)" + for pid in ${adb_dnspid} ${pids}; do + mem_dns="$((mem_dns + $("${adb_awkcmd}" '/^VmSize/{printf "%s", $2}' "/proc/${pid}/status" 2>/dev/null)))" + done + mem_dns="$("${adb_awkcmd}" -v mem="${mem_dns}" 'BEGIN{printf "%.2f", mem/1024}' 2>/dev/null)" + fi + mem_free="$("${adb_awkcmd}" '/^MemAvailable/{printf "%.2f", $2/1024}' "/proc/meminfo" 2>/dev/null)" + mem_max="$("${adb_awkcmd}" '/^VmHWM/{printf "%.2f", $2/1024}' "/proc/${$}/status" 2>/dev/null)" + adb_cnt="$("${adb_awkcmd}" -v cnt="${adb_cnt}" 'BEGIN{res="";pos=0;for(i=length(cnt);i>0;i--){res=substr(cnt,i,1)res;pos++;if(pos==3&&i>1){res="."res;pos=0;}}; printf"%s",res}')" case "${status}" in "enabled" | "error") adb_endtime="$(date "+%s")" if [ "$(((adb_endtime - adb_starttime) / 60))" -lt 60 ]; then - runtime="${adb_action}, $(((adb_endtime - adb_starttime) / 60))m $(((adb_endtime - adb_starttime) % 60))s, ${mem_free:-0} MB available, ${mem_max:-0} KB max. used, $(date -Iseconds)" + runtime="${adb_action}, $(((adb_endtime - adb_starttime) / 60))m $(((adb_endtime - adb_starttime) % 60))s, ${mem_free:-0} MB available, ${mem_max:-0} MB max. used, $(date -Iseconds)" else - runtime="${adb_action}, n/a, ${mem_free:-0} MB available, ${mem_max:-0} KB max. used, $(date -Iseconds)" + runtime="${adb_action}, n/a, ${mem_free:-0} MB available, ${mem_max:-0} MB max. used, $(date -Iseconds)" fi [ "${status}" = "error" ] && adb_cnt="0" ;; @@ -1042,13 +1048,13 @@ f_jsnup() { json_load_file "${adb_rtfile}" >/dev/null 2>&1 json_add_string "adblock_status" "${status:-"enabled"}" json_add_string "adblock_version" "${adb_ver}" - json_add_string "blocked_domains" "${adb_cnt:-0}" + json_add_string "blocked_domains" "${adb_cnt:-"0"}" json_add_array "active_sources" for object in ${sources:-"-"}; do json_add_string "${object}" "${object}" done json_close_array - json_add_string "dns_backend" "${adb_dns:-"-"} (${adb_dnscachecmd##*/}), ${adb_dnsdir:-"-"}" + json_add_string "dns_backend" "${adb_dns:-"-"} (${adb_dnscachecmd##*/}), ${adb_dnsdir:-"-"}, ${mem_dns:-"0"} MB" json_add_string "run_utils" "${utils:-"-"}" json_add_string "run_ifaces" "trigger: ${adb_trigger:-"-"}, report: ${adb_repiface:-"-"}" json_add_string "run_directories" "base: ${adb_tmpbase}, backup: ${adb_backupdir}, report: ${adb_reportdir}, jail: ${adb_jaildir}" @@ -1082,13 +1088,20 @@ f_log() { # main function for blocklist processing # f_main() { - local src_tmpload src_tmpfile src_name src_rset src_url src_log src_arc src_cat src_item src_list src_entries src_suffix src_rc entry cnt + local src_tmpload src_tmpfile src_name src_rset src_url src_arc src_cat src_item src_list src_entries src_suffix src_rc entry cnt # white- and blacklist preparation # + cnt="1" for entry in ${adb_locallist}; do - (f_list "${entry}" "${entry}") & + ( + f_list "${entry}" "${entry}" + ) & + hold="$((cnt % adb_cores))" + [ "${hold}" = "0" ] && wait + cnt="$((cnt + 1))" done + wait if [ "${adb_dns}" != "raw" ] && [ "${adb_jail}" = "1" ] && [ "${adb_jaildir}" = "${adb_dnsdir}" ]; then printf "%b" "${adb_dnsheader}" >"${adb_dnsdir}/${adb_dnsfile}" @@ -1114,7 +1127,9 @@ f_main() { [ -z "${adb_safesearchlist}" ] && adb_safesearchlist="google bing duckduckgo pixabay yandex youtube" cnt="1" for entry in ${adb_safesearchlist}; do - (f_list safesearch "${entry}") & + ( + f_list safesearch "${entry}" + ) & hold="$((cnt % adb_cores))" [ "${hold}" = "0" ] && wait cnt="$((cnt + 1))" @@ -1161,7 +1176,7 @@ f_main() { if [ -n "${src_cat}" ]; then ( src_arc="${adb_tmpdir}/${src_url##*/}" - src_log="$("${adb_fetchutil}" ${adb_fetchparm} "${src_arc}" "${src_url}" 2>&1)" + "${adb_fetchutil}" ${adb_fetchparm} "${src_arc}" "${src_url}" >/dev/null 2>&1 src_rc="${?}" if [ "${src_rc}" = "0" ] && [ -s "${src_arc}" ]; then src_suffix="$(eval printf "%s" \"\$\{adb_src_suffix_${src_name}:-\"domains\"\}\")" @@ -1175,8 +1190,7 @@ f_main() { fi : >"${src_arc}" else - src_log="$(printf "%s" "${src_log}" | "${adb_awkcmd}" '{ORS=" ";print $0}')" - f_log "info" "download of '${src_name}' failed, url: ${src_url}, rule: ${src_rset:-"-"}, categories: ${src_cat:-"-"}, rc: ${src_rc}, log: ${src_log:-"-"}" + f_log "info" "download of '${src_name}' failed, url: ${src_url}, rule: ${src_rset:-"-"}, categories: ${src_cat:-"-"}, rc: ${src_rc}" fi if [ "${src_rc}" = "0" ] && [ -s "${src_tmpload}" ]; then "${adb_awkcmd}" "${src_rset}" "${src_tmpload}" | "${adb_sedcmd}" "s/\r//g" | @@ -1212,14 +1226,14 @@ f_main() { ( for suffix in ${src_cat:-${src_url}}; do if [ "${src_url}" != "${suffix}" ]; then - src_log="$("${adb_fetchutil}" ${adb_fetchparm} "${src_tmpcat}" "${src_url}${suffix}" 2>&1)" + "${adb_fetchutil}" ${adb_fetchparm} "${src_tmpcat}" "${src_url}${suffix}" >/dev/null 2>&1 src_rc="${?}" if [ "${src_rc}" = "0" ] && [ -s "${src_tmpcat}" ]; then "${adb_catcmd}" "${src_tmpcat}" >>"${src_tmpload}" : >"${src_tmpcat}" fi else - src_log="$("${adb_fetchutil}" ${adb_fetchparm} "${src_tmpload}" "${src_url}" 2>&1)" + "${adb_fetchutil}" ${adb_fetchparm} "${src_tmpload}" "${src_url}" >/dev/null 2>&1 src_rc="${?}" fi done @@ -1237,8 +1251,7 @@ f_main() { : >"${src_tmpfile}" fi else - src_log="$(printf "%s" "${src_log}" | "${adb_awkcmd}" '{ORS=" ";print $0}')" - f_log "info" "download of '${src_name}' failed, url: ${src_url}, rule: ${src_rset:-"-"}, categories: ${src_cat:-"-"}, rc: ${src_rc}, log: ${src_log:-"-"}" + f_log "info" "download of '${src_name}' failed, url: ${src_url}, rule: ${src_rset:-"-"}, categories: ${src_cat:-"-"}, rc: ${src_rc}" [ "${adb_backup}" = "1" ] && [ "${adb_action}" != "start" ] && f_list restore fi ) & @@ -1468,11 +1481,6 @@ case "${adb_action}" in "stop") f_rmdns ;; - "restart") - f_rmdns - f_env - f_main - ;; "suspend") [ "${adb_dns}" != "raw" ] && f_switch suspend ;; @@ -1485,7 +1493,7 @@ case "${adb_action}" in "query") f_query "${2}" ;; - "start" | "reload") + "start" | "reload" | "restart") f_env f_main ;;