adblock: fix redirection issues 1971/head
authorDirk Brenken <dirk@brenken.org>
Sun, 15 Nov 2015 20:17:53 +0000 (21:17 +0100)
committerDirk Brenken <dirk@brenken.org>
Mon, 16 Nov 2015 09:10:24 +0000 (10:10 +0100)
fix more corner cases because of mksh to ash migration
fix logical glitch during startup

Signed-off-by: Dirk Brenken <dirk@brenken.org>
net/adblock/Makefile
net/adblock/files/adblock-helper.sh
net/adblock/files/adblock-update.sh

index de89597b6bfab6d3820bfcabdd2e07711a199a9d..f8c157b1bd3549a708e8b9672eb160bdf1914cb5 100644 (file)
@@ -7,7 +7,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=adblock
-PKG_VERSION:=0.20.2
+PKG_VERSION:=0.20.3
 PKG_RELEASE:=1
 PKG_LICENSE:=GPL-3.0+
 PKG_MAINTAINER:=Dirk Brenken <dirk@brenken.org>
index 944ad8f8b003510c3a58175bd0e466ec25de919d..5b795ebb623040efbd108bb38278e8de482539be 100644 (file)
@@ -276,7 +276,7 @@ f_envcheck()
         query_ok="false"
         if [ -s "${query_pid}" ]
         then
-            kill -9 $(< "${query_pid}") 2>/dev/null
+            kill -9 $(cat "${query_pid}") 2>/dev/null
             > "${query_pid}"
             /usr/bin/logger -t "adblock[${pid}]" "info: remove old dns query log background process"
         fi
@@ -392,14 +392,14 @@ f_remove()
         query_date="$(date "+%Y%m%d")"
         if [ -s "${query_pid}" ] && [ ! -f "${adb_queryfile}.${query_date}" ]
         then
-            kill -9 $(< "${query_pid}") 2>/dev/null
+            kill -9 $(cat "${query_pid}") 2>/dev/null
             > "${query_pid}"
             find "${adb_backupdir}" -maxdepth 1 -type f -mtime +${adb_queryhistory} -name "${query_name}.*" -exec rm -f {} \; 2>/dev/null
             /usr/bin/logger -t "adblock[${pid}]" "info: remove old dns query log background process and do logfile housekeeping"
         fi
         if [ ! -s "${query_pid}" ]
         then
-            ( logread -f 2>/dev/null & printf -n "$!" > "${query_pid}" ) | egrep -o "(query\[A\].*)|([a-z0-9\.\-]* is ${query_ip}$)" >> "${adb_queryfile}.${query_date}" &
+            ( logread -f 2>/dev/null & printf "$!" > "${query_pid}" ) | egrep -o "(query\[A\].*)|([a-z0-9\.\-]* is ${query_ip}$)" >> "${adb_queryfile}.${query_date}" &
             /usr/bin/logger -t "adblock[${pid}]" "info: start new domain query log background process"
         fi
     fi
@@ -423,11 +423,11 @@ f_restore()
     then
         cp -f "${adb_backupfile}" "${adb_dnsfile}" 2>/dev/null
         /usr/bin/logger -t "adblock[${pid}]" "error: ${restore_msg}, adlist backup restored"
-        printf "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: ${restore_msg}, adlist backup restored" >> "${adb_logfile}"
+        printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: ${restore_msg}, adlist backup restored" >> "${adb_logfile}"
     else
         > "${adb_dnsfile}"
         /usr/bin/logger -t "adblock[${pid}]" "error: ${restore_msg}, empty adlist generated"
-        printf "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: ${restore_msg}, empty adlist generated" >> "${adb_logfile}"
+        printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: ${restore_msg}, empty adlist generated" >> "${adb_logfile}"
     fi
 
     # restart dnsmasq
@@ -455,7 +455,7 @@ f_wancheck()
             do
                 if [ -d "/sys/class/net/${dev}" ]
                 then
-                    dev_out=$(< /sys/class/net/${dev}/operstate 2>/dev/null)
+                    dev_out="$(cat /sys/class/net/${dev}/operstate 2>/dev/null)"
                     if [ "${dev_out}" = "up" ]
                     then
                         /usr/bin/logger -t "adblock[${pid}]" "info: get wan/update interface: ${dev}, after ${cnt} loops"
@@ -464,8 +464,9 @@ f_wancheck()
                 fi
                 if [ $((cnt)) -eq $((max_cnt)) ]
                 then
+                    wan_ok="false"
                     /usr/bin/logger -t "adblock[${pid}]" "error: no wan/update interface(s) found (${adb_wandev})"
-                    printf "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: no wan/update interface(s) found (${adb_wandev})" >> "${adb_logfile}"
+                    printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: no wan/update interface(s) found (${adb_wandev})" >> "${adb_logfile}"
                     restore_msg="no wan/update interface(s)"
                     f_restore
                 fi
@@ -506,7 +507,7 @@ f_ntpcheck()
             then
                 ntp_ok="false"
                 /usr/bin/logger -t "adblock[${pid}]" "error: ntp time sync failed (${adb_ntpsrv})"
-                printf "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: ntp time sync failed (${adb_ntpsrv})" >> "${adb_logfile}"
+                printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: ntp time sync failed (${adb_ntpsrv})" >> "${adb_logfile}"
                 restore_msg="time sync failed"
                 f_restore
             fi
index cd5ce04d41958aaade9ee3de89ed5f20e108375e..2fb49b6456ab1316f7ec038aa770bb21b2205aae 100755 (executable)
@@ -25,7 +25,7 @@
 
 # set script version
 #
-adb_version="0.20.2"
+adb_version="0.20.3"
 
 # get current pid and script directory
 #
@@ -66,13 +66,13 @@ f_envparse
 #
 f_envcheck
 
-# check wan update interface(s)
+# check ntp time sync
 #
-f_wancheck
+f_ntpcheck
 
-# check for ntp time sync
+# check wan update interface(s)
 #
-f_ntpcheck
+f_wancheck
 
 # check/start shallalist (pre-)processing
 #
@@ -89,7 +89,7 @@ then
         /usr/bin/logger -t "adblock[${pid}]" "info: shallalist archive download finished"
     else
         /usr/bin/logger -t "adblock[${pid}]" "error: shallalist archive download failed (${adb_arc_shalla})"
-        printf "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: shallalist archive download failed (${adb_arc_shalla})" >> "${adb_logfile}"
+        printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: shallalist archive download failed (${adb_arc_shalla})" >> "${adb_logfile}"
         restore_msg="archive download failed"
         f_restore
     fi
@@ -103,7 +103,7 @@ then
         /usr/bin/logger -t "adblock[${pid}]" "info: shallalist archive extraction finished"
     else
         /usr/bin/logger -t "adblock[${pid}]" "error: shallalist archive extraction failed"
-        printf "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: shallalist archive extraction failed" >> "${adb_logfile}"
+        printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: shallalist archive extraction failed" >> "${adb_logfile}"
         restore_msg="archive extraction failed"
         f_restore
     fi
@@ -134,7 +134,7 @@ then
         /usr/bin/logger -t "adblock[${pid}]" "info: shallalist (pre-)processing finished (${adb_cat_shalla})"
     else
         /usr/bin/logger -t "adblock[${pid}]" "error: shallalist (pre-)processing failed (${rc}, ${adb_cat_shalla})"
-        printf "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: shallalist (pre-)processing failed (${rc}, ${adb_cat_shalla})" >> "${adb_logfile}"
+        printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: shallalist (pre-)processing failed (${rc}, ${adb_cat_shalla})" >> "${adb_logfile}"
         restore_msg="shallalist merge failed"
         f_restore
     fi
@@ -172,7 +172,7 @@ do
         /usr/bin/logger -t "adblock[${pid}]" "info: empty source download finished (${url})"
     else
         /usr/bin/logger -t "adblock[${pid}]" "error: source download failed (${url})"
-        printf "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: source download failed (${url})" >> "${adb_logfile}"
+        printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: source download failed (${url})" >> "${adb_logfile}"
         restore_msg="download failed"
         f_restore
     fi