diff --git a/net/adblock/Makefile b/net/adblock/Makefile index ef5d4e41b..d294ca7f6 100644 --- a/net/adblock/Makefile +++ b/net/adblock/Makefile @@ -7,10 +7,10 @@ include $(TOPDIR)/rules.mk PKG_NAME:=adblock -PKG_VERSION:=1.1.2 +PKG_VERSION:=1.1.10 PKG_RELEASE:=1 PKG_LICENSE:=GPL-3.0+ -PKG_MAINTAINER:=Dirk Brenken +PKG_MAINTAINER:=Dirk Brenken include $(INCLUDE_DIR)/package.mk diff --git a/net/adblock/files/README.md b/net/adblock/files/README.md index c3e52caa6..c3e0d0e5d 100644 --- a/net/adblock/files/README.md +++ b/net/adblock/files/README.md @@ -1,4 +1,4 @@ -# adblock script for openwrt +# dns based ad/abuse domain blocking ## Description A lot of people already use adblocker plugins within their desktop browsers, but what if you are using your (smart) phone, tablet, watch or any other wlan gadget...getting rid of annoying ads, trackers and other abuse sites (like facebook ;-) is simple: block them with your router. When the dns server on your router receives dns requests, you will sort out queries that ask for the resource records of ad servers and return the local ip address of your router and the internal web server delivers a transparent pixel instead. @@ -46,7 +46,7 @@ A lot of people already use adblocker plugins within their desktop browsers, but * [zeus tracker](https://zeustracker.abuse.ch) * => daily updates, approx. 440 entries * zero-conf like automatic installation & setup, usually no manual changes needed (i.e. ip address, network devices etc.) -* supports a wide range of router modes, as long as the firewall and the DNS server are enabled +* supports a wide range of router modes (incl. AP mode), as long as the firewall and the DNS server are enabled * full IPv4 and IPv6 support * each blocklist source will be updated and processed separately * timestamp check to download and process only updated adblock list sources @@ -61,18 +61,19 @@ A lot of people already use adblocker plugins within their desktop browsers, but * use dynamic iptables rulesets for adblock related redirects/rejects * openwrt init system support (start/stop/restart/reload) * hotplug support, the adblock start will be triggered by wan 'ifup' event -* optional: adblock list backup/restore (disabled by default) +* optional: automatic adblock list backup/restore, backups will be (de-)compressed on the fly (disabled by default) * optional: add new adblock sources via uci config (see example below) ## Prerequisites * [openwrt](https://openwrt.org), tested with latest stable release (Chaos Calmer) and with current trunk (Designated Driver) -* usual openwrt setup with enabled 'iptables', 'dnsmasq' and 'uhttpd' - dump AP modes are _not_ supported! +* [LEDE project](https://www.lede-project.org), tested with trunk > r98 +* usual openwrt setup with enabled 'iptables', 'dnsmasq' and 'uhttpd' - dump AP modes without these basics are _not_ supported! * additional required software packages: * wget * optional: 'kmod-ipt-nat6' for IPv6 support * the above dependencies and requirements will be checked during package installation & script runtime -## Designated Driver Installation & Usage +## OpenWrt / LEDE trunk Installation & Usage * install 'adblock' (_opkg install adblock_) * adblock starts automatically during boot/wan-ifup event, check _logread -e "adblock"_ for adblock related information * optional: start/restart/stop the adblock service manually with _/etc/init.d/adblock_ @@ -94,12 +95,13 @@ A lot of people already use adblocker plugins within their desktop browsers, but * install the packages with _opkg install <...>_ as described above ## Tweaks -* to process & store all blocklist sources at once it might helpful to enlarge your temp directory with a swap partition => see [openwrt wiki](https://wiki.openwrt.org/doc/uci/fstab) for further details -* add domain white- or blacklist entries to always-allow or -deny certain (sub) domains, by default both lists are located in _/etc/adblock_. Please add one domain per line - ip addresses, wildcards & regex are _not_ allowed (see example below) -* enable the backup/restore feature, to restore automatically the latest stable backup of your adblock lists in case of any (partial) processing error (i.e. a single blocklist source is down). Please use an (external) solid partition and _not_ your volatile router temp directory for this -* for a scheduled call of the adblock service via _/etc/init.d/adblock start_ add an appropriate crontab entry (see example below) -* in case of any script runtime errors, you should enable script debugging: for this please change the 'DEBUG' variable in the header of _/usr/bin/adblock-update.sh_ from '0' to '1' and start this script afterwards (without any parameter) -* you could add new blocklist sources on your own via uci config, all you need is a source url and an awk one-liner (see example below) +* **storage:** to process & store all blocklist sources at once it might helpful to enlarge your temp directory with a swap partition => see [openwrt wiki](https://wiki.openwrt.org/doc/uci/fstab) for further details +* **white-/blacklist:** add domain white- or blacklist entries to always-allow or -deny certain (sub) domains, by default both lists are located in _/etc/adblock_. Please add one domain per line - ip addresses, wildcards & regex are _not_ allowed (see example below) +* **backup/restore:** enable the backup/restore feature, to restore automatically the latest compressed backup of your adblock lists in case of any processing error (i.e. a single blocklist source is down). Please use an (external) solid partition and _not_ your volatile router temp directory for this +* **list updates:** for a scheduled call of the adblock service add an appropriate crontab entry (see example below) +* **new list sources:** you could add new blocklist sources on your own via uci config, all you need is a source url and an awk one-liner (see example below) +* **AP mode:** in AP mode adblock uses automatically the local router ip as nullip address. To make sure that your LuCI interface will be still accessible, please change the local uhttpd instance to ports <> 80/443 (see example below) +* **debugging:** for script debugging please change the 'DEBUG' variable in the header of _/usr/bin/adblock-update.sh_ from '0' to '1' and start this script directly (without any parameters) ## Further adblock config options * usually the adblock autodetection works quite well and no manual config overrides are needed, all options apply to the 'global' config section: @@ -107,13 +109,13 @@ A lot of people already use adblocker plugins within their desktop browsers, but * adb\_cfgversion => config version string (do not change!) - adblock will check this entry during startup * adb\_lanif => name of the logical lan interface (default: 'lan') * adb\_nullport => port of the adblock uhttpd instance (default: '65535') - * adb\_nullipv4 => IPv4 blackhole ip address (default: '192.0.2.1') - * adb\_nullipv6 => IPv6 blackhole ip address (default: '::ffff:c000:0201') + * adb\_nullipv4 => IPv4 blackhole ip address (default: '192.0.2.1', in AP mode: local router ip) + * adb\_nullipv6 => IPv6 blackhole ip address (default: '::ffff:c000:0201', in AP mode: local router ip) * adb\_forcedns => redirect all DNS queries to local dnsmasq resolver (default: '1', enabled) ## Examples -**example cronjob for a regular update of the block lists:** +**example cronjob for a regular block list update:**

 # configuration found in /etc/crontabs/root
 # start adblock script once a day at 6 a.m.
@@ -147,6 +149,16 @@ This rule removes _all_ domains from the blocklists with this string in it, i.e.
   photos.daily-deals.analoganalytics.com  
   adblockanalytics.com  
   
+**example uhttpd configuration in AP mode:**
+

+# configuration found in /etc/config/uhttpd
+# change default http/https ports <> 80/443
+#
+config uhttpd 'main'
+    list listen_http '0.0.0.0:88'
+    list listen_https '0.0.0.0:445'
+
+ **example to add a new blocklist source:**

 1. the easy way ...
@@ -177,14 +189,15 @@ If your awk one-liner works quite well, add a new source section in adblock conf
 
## Background -This adblock package is a dns/dnsmasq based adblock solution for openwrt. +This adblock package is a dns/dnsmasq based adblock solution. Queries to ad/abuse domains are never forwarded and always replied with a local IP address which may be IPv4 or IPv6. -For that purpose adblock uses an ip address from the private 'TEST-NET-1' subnet (192.0.2.1 / ::ffff:c000:0201) by default. +For that purpose adblock uses an ip address from the private 'TEST-NET-1' subnet (192.0.2.1 / ::ffff:c000:0201) by default (in AP mode the local router ip address will be used). Furthermore all ad/abuse queries will be filtered by ip(6)tables and redirected to internal adblock pixel server (in PREROUTING chain) or rejected (in FORWARD or OUTPUT chain). All iptables and uhttpd related adblock additions are non-destructive, no hard-coded changes in 'firewall.user', 'uhttpd' config or any other openwrt related config files. There is _no_ adblock background daemon running, the (scheduled) start of the adblock service keeps only the adblock lists up-to-date. +--ifup event ## Support -Please join the adblock discussion in this [openwrt forum thread](https://forum.openwrt.org/viewtopic.php?id=59803) or contact me by mail +Please join the adblock discussion in this [openwrt forum thread](https://forum.openwrt.org/viewtopic.php?id=59803) or contact me by mail ## Removal * stop all adblock related services with _/etc/init.d/adblock stop_ diff --git a/net/adblock/files/adblock-helper.sh b/net/adblock/files/adblock-helper.sh index 5cf6831e6..b91fc0dc3 100644 --- a/net/adblock/files/adblock-helper.sh +++ b/net/adblock/files/adblock-helper.sh @@ -1,6 +1,6 @@ #!/bin/sh # function library used by adblock-update.sh -# written by Dirk Brenken (openwrt@brenken.org) +# written by Dirk Brenken (dev@brenken.org) # f_envload: load adblock environment # @@ -105,12 +105,25 @@ f_envload() config_foreach parse_config service config_foreach parse_config source + # set more script defaults (can't be overwritten by adblock config options) + # + adb_minspace=12000 + adb_tmpfile="$(mktemp -tu)" + adb_tmpdir="$(mktemp -p /tmp -d)" + adb_dnsdir="/tmp/dnsmasq.d" + adb_dnsprefix="adb_list" + adb_uci="$(which uci)" + adb_iptv4="$(which iptables)" + adb_iptv6="$(which ip6tables)" + adb_fetch="$(which wget-ssl)" + unset adb_srclist adb_revsrclist adb_errsrclist + # check 'enabled' & 'version' config options # if [ -z "${adb_enabled}" ] || [ -z "${adb_cfgversion}" ] || [ "${adb_cfgversion}" != "${adb_scriptver%.*}" ] then - rc=125 - f_log "outdated adblock configuration found, please use latest version from '/etc/adblock/adblock.conf.default'" "${rc}" + rc=-1 + f_log "outdated adblock configuration found, please copy latest version from '/etc/adblock/adblock.conf.default' to '/etc/config/adblock'" f_exit fi if [ $((adb_enabled)) -ne 1 ] @@ -120,18 +133,25 @@ f_envload() f_exit fi - # set more script defaults (can't be overwritten by adblock config options) + # check running dnsmasq instance # - adb_minspace=12000 - adb_tmpfile="$(mktemp -tu)" - adb_tmpdir="$(mktemp -p /tmp -d)" - adb_dnsdir="/tmp/dnsmasq.d" - adb_dnsprefix="adb_list" - adb_uci="$(which uci)" - adb_iptv4="$(which iptables)" - adb_iptv6="$(which ip6tables)" - adb_fetch="$(which wget-ssl)" - unset adb_srclist adb_revsrclist adb_errsrclist + rc="$(ps | grep -q "[d]nsmasq"; printf ${?})" + if [ $((rc)) -ne 0 ] + then + rc=-1 + f_log "please enable the local dnsmasq instance to use adblock" + f_exit + fi + + # check running firewall + # + check="$(${adb_iptv4} -vnL | grep -F "DROP")" + if [ -z "${check}" ] + then + rc=-1 + f_log "please enable the local firewall to use adblock" + f_exit + fi # get lan ip addresses # @@ -139,11 +159,37 @@ f_envload() network_get_ipaddr6 adb_ipv6 "${adb_lanif}" if [ -z "${adb_ipv4}" ] && [ -z "${adb_ipv6}" ] then - rc=130 - f_log "no valid IPv4/IPv6 configuration found (${adb_lanif}), please set 'adb_lanif' manually" "${rc}" + rc=-1 + f_log "no valid IPv4/IPv6 configuration found (${adb_lanif}), please set 'adb_lanif' manually" f_exit fi + # check logical update interfaces (with default route) + # + network_find_wan adb_wanif4 + network_find_wan6 adb_wanif6 + if [ -z "${adb_wanif4}" ] && [ -z "${adb_wanif6}" ] + then + adb_wanif4="${adb_lanif}" + fi + + # check AP mode + # + if [ "${adb_wanif4}" = "${adb_lanif}" ] || [ "${adb_wanif6}" = "${adb_lanif}" ] + then + adb_nullipv4="${adb_ipv4}" + adb_nullipv6="${adb_ipv6}" + if [ "$(uci get uhttpd.main.listen_http | grep -Fo "80")" = "80" ] || + [ "$(uci get uhttpd.main.listen_https | grep -Fo "443")" = "443" ] + then + rc=-1 + f_log "AP mode detected, set local LuCI instance to ports <> 80/443" + f_exit + else + apmode_ok="true" + fi + fi + # get system release level # adb_sysver="$(printf "${pkg_list}" | grep "^base-files -")" @@ -156,14 +202,9 @@ f_envcheck() { local check - # check logical update interfaces (with default route) - # - network_find_wan adb_wanif4 - network_find_wan6 adb_wanif6 - if [ -z "${adb_wanif4}" ] && [ -z "${adb_wanif6}" ] + if [ "${apmode_ok}" = "true" ] then - adb_wanif4="true" - f_log "no valid IPv4/IPv6 interface with default route found, IPv4 mode will be assumed" + f_log "AP mode enabled" fi # check general package dependencies @@ -212,7 +253,7 @@ f_envcheck() then if [ $((av_space)) -le 2000 ] then - rc=135 + rc=125 f_log "not enough free space in '${adb_tmpdir}' (avail. ${av_space} kb)" "${rc}" f_exit else @@ -220,7 +261,7 @@ f_envcheck() fi fi else - rc=140 + rc=130 f_log "temp directory not found" "${rc}" f_exit fi @@ -256,34 +297,16 @@ f_envcheck() f_log "backup/restore will be disabled" fi - # check running dnsmasq instance & set defaults + # set dnsmasq defaults # - rc="$(ps | grep -q "[d]nsmasq"; printf ${?})" - if [ $((rc)) -eq 0 ] + if [ -n "${adb_wanif4}" ] && [ -n "${adb_wanif6}" ] then - if [ -n "${adb_wanif4}" ] && [ -n "${adb_wanif6}" ] - then - adb_dnsformat="awk -v ipv4="${adb_nullipv4}" -v ipv6="${adb_nullipv6}" '{print \"address=/\"\$0\"/\"ipv4\"\n\"\"address=/\"\$0\"/\"ipv6}'" - elif [ -n "${adb_wanif4}" ] - then - adb_dnsformat="awk -v ipv4="${adb_nullipv4}" '{print \"address=/\"\$0\"/\"ipv4}'" - else - adb_dnsformat="awk -v ipv6="${adb_nullipv6}" '{print \"address=/\"\$0\"/\"ipv6}'" - fi - else - rc=145 - f_log "please enable the local dns server to use adblock" "${rc}" - f_exit - fi - - # check running firewall - # - check="$(${adb_iptv4} -vnL | grep -F "DROP")" - if [ -z "${check}" ] + adb_dnsformat="awk -v ipv4="${adb_nullipv4}" -v ipv6="${adb_nullipv6}" '{print \"address=/\"\$0\"/\"ipv4\"\n\"\"address=/\"\$0\"/\"ipv6}'" + elif [ -n "${adb_wanif4}" ] then - rc=150 - f_log "please enable the local firewall to use adblock" "${rc}" - f_exit + adb_dnsformat="awk -v ipv4="${adb_nullipv4}" '{print \"address=/\"\$0\"/\"ipv4}'" + else + adb_dnsformat="awk -v ipv6="${adb_nullipv6}" '{print \"address=/\"\$0\"/\"ipv6}'" fi # check ipv4/iptables configuration @@ -376,7 +399,7 @@ f_depend() check="$(printf "${pkg_list}" | grep "^${package} -")" if [ -z "${check}" ] then - rc=155 + rc=135 f_log "package '${package}' not found" "${rc}" f_exit fi @@ -444,7 +467,7 @@ f_log() log_rc=", rc: ${log_rc}" log_msg="${log_msg}${log_rc}" fi - /usr/bin/logger ${log_parm} -t "adblock[${adb_pid}] ${class}" "${log_msg}" 2>&1 + "${adb_log}" ${log_parm} -t "adblock[${adb_pid}] ${class}" "${log_msg}" 2>&1 fi } @@ -469,43 +492,44 @@ f_space() # f_cntconfig() { - local list local src_name local count=0 local count_sum=0 - for list in $(ls -ASr "${adb_dnsdir}/${adb_dnsprefix}."*) + for src_name in $(ls -ASr "${adb_dnsdir}/${adb_dnsprefix}"*) do - src_name="${list/*./}" - count="$(wc -l < "${list}")" + count="$(wc -l < "${src_name}")" + src_name="${src_name#*.}" if [ -n "${adb_wanif4}" ] && [ -n "${adb_wanif6}" ] then count=$((count / 2)) fi - ${adb_uci} -q set "adblock.${src_name}.adb_src_count=${count}" + "${adb_uci}" -q set "adblock.${src_name}.adb_src_count=${count}" count_sum=$((count_sum + count)) done - ${adb_uci} -q set "adblock.global.adb_overall_count=${count_sum}" + "${adb_uci}" -q set "adblock.global.adb_overall_count=${count_sum}" } # f_rmconfig: remove counters & timestamps in given config sections # f_rmconfig() { + local src_name local rm_done="${1}" + local restore_done="${2:-false}" - for list in ${rm_done} + for src_name in ${rm_done} do - src_name="${list/*./}" - if [ -n "${restore_done}" ] + src_name="${src_name#*.}" + if [ "${restore_done}" = "true" ] then - ${adb_uci} -q set "adblock.${src_name}.adb_src_timestamp=list restored" + src_name="${src_name%.*}" + "${adb_uci}" -q set "adblock.${src_name}.adb_src_timestamp=list restored" else - ${adb_uci} -q delete "adblock.${src_name}.adb_src_count" - ${adb_uci} -q delete "adblock.${src_name}.adb_src_timestamp" + "${adb_uci}" -q delete "adblock.${src_name}.adb_src_count" + "${adb_uci}" -q delete "adblock.${src_name}.adb_src_timestamp" fi done - unset restore_done } # f_restore: restore last adblock list backups and restart dnsmasq @@ -536,10 +560,11 @@ f_restore() # if [ "${backup_ok}" = "true" ] then - restore_done="$(find "${adb_dir_backup}" -maxdepth 1 -type f -name "${adb_dnsprefix}.*" -print -exec cp -pf "{}" "${adb_dnsdir}" \;)" + restore_done="$(find "${adb_dir_backup}" -maxdepth 1 -type f -name "${adb_dnsprefix}*.gz" -print -exec cp -pf "{}" "${adb_dnsdir}" \;)" rc=${?} if [ $((rc)) -eq 0 ] && [ -n "${restore_done}" ] then + find "${adb_dnsdir}" -maxdepth 1 -type f -name "${adb_dnsprefix}*.gz" -exec gunzip -f "{}" \; f_log "all available backups restored" elif [ $((rc)) -ne 0 ] && [ -n "${restore_done}" ] then @@ -563,7 +588,7 @@ f_restore() f_cntconfig f_log "adblock lists with overall ${adb_count} domains loaded" else - rc=160 + rc=140 f_log "dnsmasq restart failed, please check 'logread' output" "${rc}" fi fi @@ -604,7 +629,7 @@ f_exit() fi if [ -n "$(${adb_uci} -q changes adblock)" ] then - ${adb_uci} -q commit "adblock" + "${adb_uci}" -q commit "adblock" fi f_log "firewall statistics (IPv4/IPv6): ${ipv4_adblock}/${ipv6_adblock} ad related packets blocked" f_log "domain adblock processing finished successfully (${adb_scriptver}, ${adb_sysver}, $(/bin/date "+%d.%m.%Y %H:%M:%S"))" @@ -612,7 +637,7 @@ f_exit() then if [ -n "$(${adb_uci} -q changes adblock)" ] then - ${adb_uci} -q revert "adblock" + "${adb_uci}" -q revert "adblock" fi f_log "domain adblock processing failed (${adb_scriptver}, ${adb_sysver}, $(/bin/date "+%d.%m.%Y %H:%M:%S"))" else diff --git a/net/adblock/files/adblock-update.sh b/net/adblock/files/adblock-update.sh index a939f868d..2185556ce 100755 --- a/net/adblock/files/adblock-update.sh +++ b/net/adblock/files/adblock-update.sh @@ -1,6 +1,6 @@ #!/bin/sh # dns based ad/abuse domain blocking script -# written by Dirk Brenken (openwrt@brenken.org) +# written by Dirk Brenken (dev@brenken.org) # This is free software, licensed under the GNU General Public License v3. # You should have received a copy of the GNU General Public License @@ -19,15 +19,16 @@ then exec 2>/dev/null fi -# pid handling +# set pid & logger # adb_pid="${$}" adb_pidfile="/var/run/adblock.pid" +adb_log="$(which logger)" if [ -r "${adb_pidfile}" ] then rc=255 - /usr/bin/logger -s -t "adblock[${adb_pid}] error" "adblock service already running ($(cat ${adb_pidfile}))" + "${adb_log}" -s -t "adblock[${adb_pid}] error" "adblock service already running ($(cat ${adb_pidfile}))" exit ${rc} else printf "${adb_pid}" > "${adb_pidfile}" @@ -36,7 +37,7 @@ fi # get current directory and script version # adb_scriptdir="${0%/*}" -adb_scriptver="1.1.2" +adb_scriptver="1.1.10" # source in adblock function library # @@ -45,7 +46,7 @@ then . "${adb_scriptdir}/adblock-helper.sh" else rc=254 - /usr/bin/logger -s -t "adblock[${adb_pid}] error" "adblock function library not found" + "${adb_log}" -s -t "adblock[${adb_pid}] error" "adblock function library not found" rm -f "${adb_pidfile}" exit ${rc} fi @@ -81,7 +82,7 @@ do # if [ -z "${url}" ] || [ -z "${src_rset}" ] then - ${adb_uci} -q set "adblock.${src_name}.adb_src_timestamp=broken config" + "${adb_uci}" -q set "adblock.${src_name}.adb_src_timestamp=broken config" f_log " broken source configuration, check 'adb_src' and 'adb_src_rset' in config" continue fi @@ -90,9 +91,9 @@ do # if [ -z "${adb_srclist}" ] then - adb_srclist="! -name ${adb_dnsprefix}.${src_name}" + adb_srclist="! -name ${adb_dnsprefix}.${src_name}*" else - adb_srclist="${adb_srclist} -a ! -name ${adb_dnsprefix}.${src_name}" + adb_srclist="${adb_srclist} -a ! -name ${adb_dnsprefix}.${src_name}*" fi # only download adblock list with newer/updated timestamp @@ -109,7 +110,7 @@ do f_log " no online timestamp received, current date will be used" fi if [ -z "${list_time}" ] || [ "${list_time}" != "${url_time}" ] || [ ! -r "${adb_dnsfile}" ] ||\ - ([ "${backup_ok}" = "true" ] && [ ! -r "${adb_dir_backup}/${adb_dnsprefix}.${src_name}" ]) + ([ "${backup_ok}" = "true" ] && [ ! -r "${adb_dir_backup}/${adb_dnsprefix}.${src_name}.gz" ]) then if [ "${src_name}" = "blacklist" ] then @@ -119,7 +120,7 @@ do then shalla_archive="${adb_tmpdir}/shallalist.tar.gz" shalla_file="${adb_tmpdir}/shallalist.txt" - ${adb_fetch} ${fetch_parm} --output-document="${shalla_archive}" "${url}" + "${adb_fetch}" ${fetch_parm} --output-document="${shalla_archive}" "${url}" rc=${?} if [ $((rc)) -eq 0 ] then @@ -161,18 +162,18 @@ do unset tmp_domains elif [ $((rc)) -eq 0 ] && [ -z "${tmp_domains}" ] then - ${adb_uci} -q set "adblock.${src_name}.adb_src_timestamp=empty download" + "${adb_uci}" -q set "adblock.${src_name}.adb_src_timestamp=empty download" f_log " empty source download finished" continue else rc=0 if [ -z "${adb_errsrclist}" ] then - adb_errsrclist="-name ${adb_dnsprefix}.${src_name}" + adb_errsrclist="-name ${adb_dnsprefix}.${src_name}.gz" else - adb_errsrclist="${adb_errsrclist} -o -name ${adb_dnsprefix}.${src_name}" + adb_errsrclist="${adb_errsrclist} -o -name ${adb_dnsprefix}.${src_name}.gz" fi - ${adb_uci} -q set "adblock.${src_name}.adb_src_timestamp=download failed" + "${adb_uci}" -q set "adblock.${src_name}.adb_src_timestamp=download failed" f_log " source download failed" continue fi @@ -204,14 +205,14 @@ do # if [ $((rc)) -eq 0 ] then - ${adb_uci} -q set "adblock.${src_name}.adb_src_timestamp=${url_time}" + "${adb_uci}" -q set "adblock.${src_name}.adb_src_timestamp=${url_time}" f_log " domain merging finished" else f_log " domain merging failed" "${rc}" f_restore fi else - ${adb_uci} -q set "adblock.${src_name}.adb_src_timestamp=empty domain input" + "${adb_uci}" -q set "adblock.${src_name}.adb_src_timestamp=empty domain input" f_log " empty domain input received" continue fi @@ -221,18 +222,18 @@ done # if [ -n "${adb_srclist}" ] then - rm_done="$(find "${adb_dnsdir}" -maxdepth 1 -type f -name "${adb_dnsprefix}.*" \( ${adb_srclist} \) -print -exec rm -f "{}" \;)" + rm_done="$(find "${adb_dnsdir}" -maxdepth 1 -type f \( ${adb_srclist} \) -print -exec rm -f "{}" \;)" rc=${?} - if [ "${backup_ok}" = "true" ] + if [ "${backup_ok}" = "true" ] && [ -n "${rm_done}" ] then - find "${adb_dir_backup}" -maxdepth 1 -type f -name "${adb_dnsprefix}.*" \( ${adb_srclist} \) -exec rm -f "{}" \; + find "${adb_dir_backup}" -maxdepth 1 -type f \( ${adb_srclist} \) -exec rm -f "{}" \; fi else - rm_done="$(find "${adb_dnsdir}" -maxdepth 1 -type f -name "${adb_dnsprefix}.*" -print -exec rm -f "{}" \;)" + rm_done="$(find "${adb_dnsdir}" -maxdepth 1 -type f -name "${adb_dnsprefix}*" -print -exec rm -f "{}" \;)" rc=${?} if [ "${backup_ok}" = "true" ] then - find "${adb_dir_backup}" -maxdepth 1 -type f -name "${adb_dnsprefix}.*" -exec rm -f "{}" \; + find "${adb_dir_backup}" -maxdepth 1 -type f -name "${adb_dnsprefix}*" -exec rm -f "{}" \; fi fi if [ $((rc)) -eq 0 ] && [ -n "${rm_done}" ] @@ -253,7 +254,8 @@ then rc=${?} if [ $((rc)) -eq 0 ] && [ -n "${restore_done}" ] then - f_rmconfig "${restore_done}" + find "${adb_dnsdir}" -maxdepth 1 -type f -name "${adb_dnsprefix}*.gz" -exec gunzip -f "{}" \; + f_rmconfig "${restore_done}" "true" f_log "partial restore done" elif [ $((rc)) -ne 0 ] then @@ -274,7 +276,7 @@ then # loop through all separate lists, ordered by size (ascending) # - for list in $(ls -ASr "${adb_dnsdir}/${adb_dnsprefix}."*) + for list in $(ls -ASr "${adb_dnsdir}/${adb_dnsprefix}"*) do # check overall block list vs. separate block list, # write all duplicate entries to separate list @@ -320,6 +322,7 @@ then rc=${?} if [ $((rc)) -eq 0 ] && [ -n "${backup_done}" ] then + find "${adb_dir_backup}" -maxdepth 1 -type f \( -name "${adb_dnsprefix}*" -a ! -name "${adb_dnsprefix}*.gz" \) -exec gzip -f "{}" \; f_log "new adblock list backups generated" elif [ $((rc)) -ne 0 ] && [ -n "${backup_done}" ] then