Browse Source

adblock: fix redirection issues

fix more corner cases because of mksh to ash migration
fix logical glitch during startup

Signed-off-by: Dirk Brenken <dirk@brenken.org>
Dirk Brenken 9 years ago
parent
commit
3dc3e1d214
3 changed files with 19 additions and 18 deletions
  1. 1
    1
      net/adblock/Makefile
  2. 9
    8
      net/adblock/files/adblock-helper.sh
  3. 9
    9
      net/adblock/files/adblock-update.sh

+ 1
- 1
net/adblock/Makefile View File

@@ -7,7 +7,7 @@
7 7
 include $(TOPDIR)/rules.mk
8 8
 
9 9
 PKG_NAME:=adblock
10
-PKG_VERSION:=0.20.2
10
+PKG_VERSION:=0.20.3
11 11
 PKG_RELEASE:=1
12 12
 PKG_LICENSE:=GPL-3.0+
13 13
 PKG_MAINTAINER:=Dirk Brenken <dirk@brenken.org>

+ 9
- 8
net/adblock/files/adblock-helper.sh View File

@@ -276,7 +276,7 @@ f_envcheck()
276 276
         query_ok="false"
277 277
         if [ -s "${query_pid}" ]
278 278
         then
279
-            kill -9 $(< "${query_pid}") 2>/dev/null
279
+            kill -9 $(cat "${query_pid}") 2>/dev/null
280 280
             > "${query_pid}"
281 281
             /usr/bin/logger -t "adblock[${pid}]" "info: remove old dns query log background process"
282 282
         fi
@@ -392,14 +392,14 @@ f_remove()
392 392
         query_date="$(date "+%Y%m%d")"
393 393
         if [ -s "${query_pid}" ] && [ ! -f "${adb_queryfile}.${query_date}" ]
394 394
         then
395
-            kill -9 $(< "${query_pid}") 2>/dev/null
395
+            kill -9 $(cat "${query_pid}") 2>/dev/null
396 396
             > "${query_pid}"
397 397
             find "${adb_backupdir}" -maxdepth 1 -type f -mtime +${adb_queryhistory} -name "${query_name}.*" -exec rm -f {} \; 2>/dev/null
398 398
             /usr/bin/logger -t "adblock[${pid}]" "info: remove old dns query log background process and do logfile housekeeping"
399 399
         fi
400 400
         if [ ! -s "${query_pid}" ]
401 401
         then
402
-            ( logread -f 2>/dev/null & printf -n "$!" > "${query_pid}" ) | egrep -o "(query\[A\].*)|([a-z0-9\.\-]* is ${query_ip}$)" >> "${adb_queryfile}.${query_date}" &
402
+            ( logread -f 2>/dev/null & printf "$!" > "${query_pid}" ) | egrep -o "(query\[A\].*)|([a-z0-9\.\-]* is ${query_ip}$)" >> "${adb_queryfile}.${query_date}" &
403 403
             /usr/bin/logger -t "adblock[${pid}]" "info: start new domain query log background process"
404 404
         fi
405 405
     fi
@@ -423,11 +423,11 @@ f_restore()
423 423
     then
424 424
         cp -f "${adb_backupfile}" "${adb_dnsfile}" 2>/dev/null
425 425
         /usr/bin/logger -t "adblock[${pid}]" "error: ${restore_msg}, adlist backup restored"
426
-        printf "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: ${restore_msg}, adlist backup restored" >> "${adb_logfile}"
426
+        printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: ${restore_msg}, adlist backup restored" >> "${adb_logfile}"
427 427
     else
428 428
         > "${adb_dnsfile}"
429 429
         /usr/bin/logger -t "adblock[${pid}]" "error: ${restore_msg}, empty adlist generated"
430
-        printf "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: ${restore_msg}, empty adlist generated" >> "${adb_logfile}"
430
+        printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: ${restore_msg}, empty adlist generated" >> "${adb_logfile}"
431 431
     fi
432 432
 
433 433
     # restart dnsmasq
@@ -455,7 +455,7 @@ f_wancheck()
455 455
             do
456 456
                 if [ -d "/sys/class/net/${dev}" ]
457 457
                 then
458
-                    dev_out=$(< /sys/class/net/${dev}/operstate 2>/dev/null)
458
+                    dev_out="$(cat /sys/class/net/${dev}/operstate 2>/dev/null)"
459 459
                     if [ "${dev_out}" = "up" ]
460 460
                     then
461 461
                         /usr/bin/logger -t "adblock[${pid}]" "info: get wan/update interface: ${dev}, after ${cnt} loops"
@@ -464,8 +464,9 @@ f_wancheck()
464 464
                 fi
465 465
                 if [ $((cnt)) -eq $((max_cnt)) ]
466 466
                 then
467
+                    wan_ok="false"
467 468
                     /usr/bin/logger -t "adblock[${pid}]" "error: no wan/update interface(s) found (${adb_wandev})"
468
-                    printf "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: no wan/update interface(s) found (${adb_wandev})" >> "${adb_logfile}"
469
+                    printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: no wan/update interface(s) found (${adb_wandev})" >> "${adb_logfile}"
469 470
                     restore_msg="no wan/update interface(s)"
470 471
                     f_restore
471 472
                 fi
@@ -506,7 +507,7 @@ f_ntpcheck()
506 507
             then
507 508
                 ntp_ok="false"
508 509
                 /usr/bin/logger -t "adblock[${pid}]" "error: ntp time sync failed (${adb_ntpsrv})"
509
-                printf "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: ntp time sync failed (${adb_ntpsrv})" >> "${adb_logfile}"
510
+                printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: ntp time sync failed (${adb_ntpsrv})" >> "${adb_logfile}"
510 511
                 restore_msg="time sync failed"
511 512
                 f_restore
512 513
             fi

+ 9
- 9
net/adblock/files/adblock-update.sh View File

@@ -25,7 +25,7 @@
25 25
 
26 26
 # set script version
27 27
 #
28
-adb_version="0.20.2"
28
+adb_version="0.20.3"
29 29
 
30 30
 # get current pid and script directory
31 31
 #
@@ -66,13 +66,13 @@ f_envparse
66 66
 #
67 67
 f_envcheck
68 68
 
69
-# check wan update interface(s)
69
+# check ntp time sync
70 70
 #
71
-f_wancheck
71
+f_ntpcheck
72 72
 
73
-# check for ntp time sync
73
+# check wan update interface(s)
74 74
 #
75
-f_ntpcheck
75
+f_wancheck
76 76
 
77 77
 # check/start shallalist (pre-)processing
78 78
 #
@@ -89,7 +89,7 @@ then
89 89
         /usr/bin/logger -t "adblock[${pid}]" "info: shallalist archive download finished"
90 90
     else
91 91
         /usr/bin/logger -t "adblock[${pid}]" "error: shallalist archive download failed (${adb_arc_shalla})"
92
-        printf "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: shallalist archive download failed (${adb_arc_shalla})" >> "${adb_logfile}"
92
+        printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: shallalist archive download failed (${adb_arc_shalla})" >> "${adb_logfile}"
93 93
         restore_msg="archive download failed"
94 94
         f_restore
95 95
     fi
@@ -103,7 +103,7 @@ then
103 103
         /usr/bin/logger -t "adblock[${pid}]" "info: shallalist archive extraction finished"
104 104
     else
105 105
         /usr/bin/logger -t "adblock[${pid}]" "error: shallalist archive extraction failed"
106
-        printf "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: shallalist archive extraction failed" >> "${adb_logfile}"
106
+        printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: shallalist archive extraction failed" >> "${adb_logfile}"
107 107
         restore_msg="archive extraction failed"
108 108
         f_restore
109 109
     fi
@@ -134,7 +134,7 @@ then
134 134
         /usr/bin/logger -t "adblock[${pid}]" "info: shallalist (pre-)processing finished (${adb_cat_shalla})"
135 135
     else
136 136
         /usr/bin/logger -t "adblock[${pid}]" "error: shallalist (pre-)processing failed (${rc}, ${adb_cat_shalla})"
137
-        printf "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: shallalist (pre-)processing failed (${rc}, ${adb_cat_shalla})" >> "${adb_logfile}"
137
+        printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: shallalist (pre-)processing failed (${rc}, ${adb_cat_shalla})" >> "${adb_logfile}"
138 138
         restore_msg="shallalist merge failed"
139 139
         f_restore
140 140
     fi
@@ -172,7 +172,7 @@ do
172 172
         /usr/bin/logger -t "adblock[${pid}]" "info: empty source download finished (${url})"
173 173
     else
174 174
         /usr/bin/logger -t "adblock[${pid}]" "error: source download failed (${url})"
175
-        printf "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: source download failed (${url})" >> "${adb_logfile}"
175
+        printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: source download failed (${url})" >> "${adb_logfile}"
176 176
         restore_msg="download failed"
177 177
         f_restore
178 178
     fi