simple-adblock: bugfixes: remove escape chars from log, restore from cache on boot 11803/head
authorStan Grishin <stangri@melmac.net>
Tue, 7 Apr 2020 21:55:51 +0000 (21:55 +0000)
committerStan Grishin <stangri@melmac.net>
Tue, 7 Apr 2020 21:55:51 +0000 (21:55 +0000)
Signed-off-by: Stan Grishin <stangri@melmac.net>
net/simple-adblock/Makefile
net/simple-adblock/files/simple-adblock.conf
net/simple-adblock/files/simple-adblock.init

index 062fdff6e66376510615badf6d904a0e4095e0a4..a113b68045630aa222557bb94048015151170607 100644 (file)
@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=simple-adblock
 PKG_VERSION:=1.8.3
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 PKG_MAINTAINER:=Stan Grishin <stangri@melmac.net>
 PKG_LICENSE:=GPL-3.0-or-later
 
index 083374fd061152ef868551686077a5d366724a46..8690ca068db64bada4b9b0b48d5e632711fcbfa3 100644 (file)
@@ -70,6 +70,10 @@ config simple-adblock 'config'
 # blocklist too big for most routers
 #  list blacklist_hosts_url 'http://sysctl.org/cameleon/hosts'
 
+# File size: 1.6M
+# blocklist too big for most routers
+#      list blacklist_hosts_url 'https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts'
+
 # File size: 1.7M
 # blocklist too big for most routers
 #      list blacklist_hosts_url 'https://hosts-file.net/ad_servers.txt'
@@ -78,6 +82,9 @@ config simple-adblock 'config'
 # blocklist too big for most routers
 #      list blacklist_hosts_url 'https://hostsfile.mine.nu/Hosts'
 
+# File size: 23.0M
+# blocklist too big for most routers
+#      list blacklist_hosts_url 'https://dbl.oisd.nl/'
+
 # site was down on last check
 #      list blacklist_domains_url 'http://support.it-mate.co.uk/downloads/hosts.txt'
-
index 47935b30eed49b2a27a533f09cdbebfb7c8dd92a..aec915f5f73221dbd6b5d9b9bfdcc2f2ca6dbf59 100644 (file)
@@ -1,7 +1,6 @@
 #!/bin/sh /etc/rc.common
-# Copyright 2017-2019 Stan Grishin (stangri@melmac.net)
-# shellcheck disable=SC2039
-# shellcheck disable=SC1091
+# Copyright 2017-2020 Stan Grishin (stangri@melmac.net)
+# shellcheck disable=SC2039,SC1091
 PKG_VERSION='dev-test'
 
 export START=94
@@ -124,7 +123,7 @@ unbound_restart() { /etc/init.d/unbound restart >/dev/null 2>&1; }
 output() {
 # Can take a single parameter (text) to be output at any verbosity
 # Or target verbosity level and text to be output at specifc verbosity
-       local msg memmsg
+       local msg memmsg logmsg
        if [ $# -ne 1 ]; then
                if [ $((verbosity & $1)) -gt 0 ] || [ "$verbosity" = "$1" ]; then shift; else return 0; fi
        fi
@@ -132,7 +131,8 @@ output() {
        msg="${1//$serviceName /service }";
        if [ "$(printf "%b" "$msg" | wc -l)" -gt 0 ]; then
                [ -s "$sharedMemoryOutput" ] && memmsg="$(cat "$sharedMemoryOutput")"
-               logger -t "${packageName:-service} [$$]" "$(printf "%b" "${memmsg}${msg}")"
+               logmsg="$(printf "%b" "${memmsg}${msg}" | sed 's/\x1b\[[0-9;]*m//g')"
+               logger -t "${packageName:-service} [$$]" "$(printf "%b" "$logmsg")"
                rm -f "$sharedMemoryOutput"
        else
                printf "%b" "$msg" >> "$sharedMemoryOutput"
@@ -449,7 +449,9 @@ tmpfs() {
                                triggers)
                                        curReload="$parallelDL $debug $dlTimeout $whitelist_domains $blacklist_domains $whitelist_domains_urls $blacklist_domains_urls $blacklist_hosts_urls $targetDNS"
                                        curRestart="$compressedCache $forceDNS $led"
-                                       if [ "$curReload" != "$readReload" ]; then
+                                       if [ ! -s "$jsonFile" ]; then
+                                               ret='on_boot'
+                                       elif [ "$curReload" != "$readReload" ]; then
                                                ret='download'
                                        elif [ "$curRestart" != "$readRestart" ]; then
                                                ret='restart'
@@ -899,7 +901,7 @@ boot() {
        if create_lock; then
                sleep "$bootDelay"
                remove_lock
-               rc_procd start_service && rc_procd service_triggers
+               rc_procd start_service 'on_boot' && rc_procd service_triggers
        fi
 }
 
@@ -917,12 +919,18 @@ start_service() {
        stats="$(tmpfs get stats)"
        action="$(tmpfs get triggers)"
 
-       if [ "$action" = 'download' ] || [ "$1" = 'download' ] || [ -n "$error" ]; then
-               action='download'
-       elif [ ! -s "$outputFile" ] && ! cacheOps 'test' && ! cacheOps 'testGzip'; then
+       if [ "$action" = 'on_boot' ] || [ "$1" = 'on_boot' ]; then
+               if cacheOps 'testGzip' || cacheOps 'test'; then
+                       action='restore'
+               fi
+       elif [ "$action" = 'download' ] || [ "$1" = 'download' ] || [ -n "$error" ]; then
                action='download'
-       elif [ ! -s "$outputFile" ] && cacheOps 'testGzip' || cacheOps 'test'; then
-               action='restore'
+       elif [ ! -s "$outputFile" ]; then 
+               if cacheOps 'testGzip' || cacheOps 'test'; then
+                       action='restore'
+               else
+                       action='download'
+               fi
        elif [ "$action" = 'restart' ] || [ "$1" = 'restart' ]; then
                action='restart'
        elif [ -s "$outputFile" ] && [ "$status" = "statusSuccess" ] && [ -z "$error" ]; then