Browse Source

Merge pull request #4056 from dibdot/adblock

adblock: update 2.3.2
lilik-openwrt-22.03
Ted Hess 8 years ago
committed by GitHub
parent
commit
4a06ff6872
2 changed files with 22 additions and 19 deletions
  1. +1
    -1
      net/adblock/Makefile
  2. +21
    -18
      net/adblock/files/adblock.sh

+ 1
- 1
net/adblock/Makefile View File

@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=adblock
PKG_VERSION:=2.3.1
PKG_VERSION:=2.3.2
PKG_RELEASE:=1
PKG_LICENSE:=GPL-3.0+
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>


+ 21
- 18
net/adblock/files/adblock.sh View File

@ -10,7 +10,7 @@
#
LC_ALL=C
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
adb_ver="2.3.1"
adb_ver="2.3.2"
adb_enabled=1
adb_debug=0
adb_backup=0
@ -169,9 +169,12 @@ f_envcheck()
#
f_rmtemp()
{
rm -f "${adb_tmpload}"
rm -f "${adb_tmpfile}"
rm -rf "${adb_tmpdir}"
if [ -d "${adb_tmpdir}" ]
then
rm -f "${adb_tmpload}"
rm -f "${adb_tmpfile}"
rm -rf "${adb_tmpdir}"
fi
}
# f_rmdns: remove dns related files & directories
@ -331,9 +334,10 @@ f_log()
#
f_main()
{
local enabled url cnt sum_cnt=0
local src_name src_rset shalla_file shalla_archive list active_lists
local enabled url cnt sum_cnt=0 mem_total=0
local src_name src_rset shalla_archive list active_lists
local sysver="$(ubus -S call system board | jsonfilter -e '@.release.description')"
mem_total="$(awk '$1 ~ /^MemTotal/ {printf $2}' "/proc/meminfo" 2>/dev/null)"
f_log "info " "start adblock processing ..."
for src_name in ${adb_sources}
@ -356,7 +360,7 @@ f_main()
# download block list
#
f_log "debug" "name: ${src_name}, enabled: ${enabled}, backup: ${adb_backup}, dns: ${adb_dns}, fetch: ${adb_fetch}"
f_log "debug" "name: ${src_name}, enabled: ${enabled}, backup: ${adb_backup}, dns: ${adb_dns}, fetch: ${adb_fetch}, memory: ${mem_total}"
if [ "${src_name}" = "blacklist" ]
then
cat "${url}" 2>/dev/null > "${adb_tmpload}"
@ -364,23 +368,19 @@ f_main()
elif [ "${src_name}" = "shalla" ]
then
shalla_archive="${adb_tmpdir}/shallalist.tar.gz"
shalla_file="${adb_tmpdir}/shallalist.txt"
"${adb_fetch}" ${adb_fetchparm} "${shalla_archive}" "${url}" 2>/dev/null
adb_rc=${?}
if [ ${adb_rc} -eq 0 ]
then
> "${shalla_file}"
for category in ${adb_src_cat_shalla}
do
tar -xOzf "${shalla_archive}" BL/${category}/domains >> "${shalla_file}"
tar -xOzf "${shalla_archive}" BL/${category}/domains >> "${adb_tmpload}"
adb_rc=${?}
if [ ${adb_rc} -ne 0 ]
then
break
fi
done
cat "${shalla_file}" 2>/dev/null > "${adb_tmpload}"
rm -f "${shalla_file}"
fi
rm -f "${shalla_archive}"
rm -rf "${adb_tmpdir}/BL"
@ -424,16 +424,19 @@ f_main()
fi
done
# sort/unique overall
# overall sort
#
for src_name in $(ls -dASr "${adb_tmpdir}/${adb_dnsprefix}"* 2>/dev/null)
do
if [ -s "${adb_tmpdir}/blocklist.overall" ]
if [ ${mem_total} -ge 64000 ]
then
sort "${adb_tmpdir}/blocklist.overall" "${adb_tmpdir}/blocklist.overall" "${src_name}" | uniq -u > "${adb_tmpdir}/tmp.blocklist"
cat "${adb_tmpdir}/tmp.blocklist" > "${src_name}"
if [ -s "${adb_tmpdir}/blocklist.overall" ]
then
sort "${adb_tmpdir}/blocklist.overall" "${adb_tmpdir}/blocklist.overall" "${src_name}" | uniq -u > "${adb_tmpdir}/tmp.blocklist"
mv -f "${adb_tmpdir}/tmp.blocklist" "${src_name}"
fi
cat "${src_name}" >> "${adb_tmpdir}/blocklist.overall"
fi
cat "${src_name}" >> "${adb_tmpdir}/blocklist.overall"
cnt="$(wc -l < "${src_name}")"
sum_cnt=$((sum_cnt + cnt))
list="${src_name/*./}"
@ -449,6 +452,7 @@ f_main()
#
mv -f "${adb_tmpdir}/${adb_dnsprefix}"* "${adb_dnsdir}" 2>/dev/null
chown "${adb_dns}":"${adb_dns}" "${adb_dnsdir}/${adb_dnsprefix}"* 2>/dev/null
f_rmtemp
f_dnsrestart
if [ "${adb_dnsup}" = "true" ]
then
@ -461,7 +465,6 @@ f_main()
\"dns_backend\":\"${adb_dns}\",
\"last_rundate\":\"$(/bin/date "+%d.%m.%Y %H:%M:%S")\",
\"system\":\"${sysver}\"}}}}"
f_rmtemp
return 0
fi
f_log "error" "dns backend restart with active block lists failed (${sysver})"


Loading…
Cancel
Save