Browse Source

Merge pull request #2030 from dibdot/adblock

adblock: bugfix release
lilik-openwrt-22.03
Hannu Nyman 9 years ago
parent
commit
c508fe103a
3 changed files with 32 additions and 29 deletions
  1. +1
    -1
      net/adblock/Makefile
  2. +20
    -18
      net/adblock/files/adblock-helper.sh
  3. +11
    -10
      net/adblock/files/adblock-update.sh

+ 1
- 1
net/adblock/Makefile View File

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


+ 20
- 18
net/adblock/files/adblock-helper.sh View File

@ -138,13 +138,13 @@ f_envparse()
done done
elif [ "${config}" = "wancheck" ] elif [ "${config}" = "wancheck" ]
then then
unset adb_wandev
unset adb_wandev 2>/dev/null
elif [ "${config}" = "ntpcheck" ] elif [ "${config}" = "ntpcheck" ]
then then
unset adb_ntpsrv
unset adb_ntpsrv 2>/dev/null
elif [ "${config}" = "shalla" ] elif [ "${config}" = "shalla" ]
then then
unset adb_cat_shalla
unset adb_cat_shalla 2>/dev/null
fi fi
} }
@ -157,7 +157,7 @@ f_envparse()
# set temp variables and counter # set temp variables and counter
# #
adb_tmpfile="$(mktemp -tu 2>/dev/null)" adb_tmpfile="$(mktemp -tu 2>/dev/null)"
adb_tmpdir="$(mktemp -d 2>/dev/null)"
adb_tmpdir="$(mktemp -p /tmp -d 2>/dev/null)"
# set adblock source ruleset definitions # set adblock source ruleset definitions
# #
@ -173,14 +173,6 @@ f_envparse()
# #
adb_dnsfile="/tmp/dnsmasq.d/adlist.conf" adb_dnsfile="/tmp/dnsmasq.d/adlist.conf"
adb_dnsformat="sed 's/^/address=\//;s/$/\/'${adb_ip}'/'" adb_dnsformat="sed 's/^/address=\//;s/$/\/'${adb_ip}'/'"
# remove unused environment variables
#
env_list="$(set | grep -o "CONFIG_[A-Za-z_]*")"
for var in ${env_list}
do
unset "${var}" 2>/dev/null
done
} }
############################################# #############################################
@ -294,11 +286,11 @@ f_envcheck()
check="$(printf "${pkg_list}" | grep "^ca-certificates -")" check="$(printf "${pkg_list}" | grep "^ca-certificates -")"
if [ -z "${check}" ] if [ -z "${check}" ]
then then
curl_parm="--insecure"
wget_parm="--no-check-certificate"
curl_parm="-q --insecure"
wget_parm="--no-config --no-check-certificate"
else else
unset curl_parm
unset wget_parm
curl_parm="-q"
wget_parm="--no-config"
fi fi
# check total and swap memory # check total and swap memory
@ -424,6 +416,16 @@ f_envcheck()
f_remove f_remove
fi fi
fi fi
# remove no longer used environment variables
#
env_list="$(set | grep -o "CONFIG_[A-Za-z0-9_]*")"
for var in ${env_list}
do
unset "${var}" 2>/dev/null
done
unset env_list 2>/dev/null
unset pkg_list 2>/dev/null
} }
################################################ ################################################
@ -495,10 +497,10 @@ f_deltemp()
rm -f "${adb_tmpfile}" >/dev/null 2>&1 rm -f "${adb_tmpfile}" >/dev/null 2>&1
fi fi
if [ -d "${adb_tmpdir}" ] if [ -d "${adb_tmpdir}" ]
then
then
rm -rf "${adb_tmpdir}" >/dev/null 2>&1 rm -rf "${adb_tmpdir}" >/dev/null 2>&1
fi fi
f_log "domain adblock processing finished (${adb_version})"
f_log "domain adblock processing finished (${adb_version}, ${openwrt_version})"
exit ${rc} exit ${rc}
} }


+ 11
- 10
net/adblock/files/adblock-update.sh View File

@ -25,12 +25,13 @@
# set script version # set script version
# #
adb_version="0.22.0"
adb_version="0.22.1"
# get current pid and script directory
# get current pid, script directory and openwrt version
# #
pid=${$} pid=${$}
adb_scriptdir="${0%/*}" adb_scriptdir="${0%/*}"
openwrt_version="$(cat /etc/openwrt_version 2>/dev/null)"
# source in adblock function library # source in adblock function library
# #
@ -53,7 +54,7 @@ trap "f_log 'trap error' '600'; f_restore" 1 2 3 10 11 15
# start logging # start logging
# #
f_log "domain adblock processing started (${adb_version})"
f_log "domain adblock processing started (${adb_version}, ${openwrt_version})"
# load environment # load environment
# #
@ -75,7 +76,7 @@ then
# #
shalla_archive="${adb_tmpdir}/shallalist.tar.gz" shalla_archive="${adb_tmpdir}/shallalist.tar.gz"
shalla_file="${adb_tmpdir}/shallalist.txt" shalla_file="${adb_tmpdir}/shallalist.txt"
curl "${curl_parm}" --max-time "${adb_maxtime}" "${adb_arc_shalla}" -o "${shalla_archive}" 2>/dev/null
curl ${curl_parm} --max-time "${adb_maxtime}" "${adb_arc_shalla}" --output "${shalla_archive}" 2>/dev/null
rc=${?} rc=${?}
if [ $((rc)) -eq 0 ] if [ $((rc)) -eq 0 ]
then then
@ -96,7 +97,7 @@ then
then then
if [ -r "${adb_tmpdir}/BL/${category}/domains" ] if [ -r "${adb_tmpdir}/BL/${category}/domains" ]
then then
cat "${adb_tmpdir}/BL/${category}/domains" >> "${shalla_file}" 2>/dev/null
cat "${adb_tmpdir}/BL/${category}/domains" 2>/dev/null >> "${shalla_file}"
fi fi
else else
f_log "shallalist archive extraction failed (${category})" "${rc}" f_log "shallalist archive extraction failed (${category})" "${rc}"
@ -124,10 +125,10 @@ do
check_url="$(printf "${url}" | sed -n '/^https:/p')" check_url="$(printf "${url}" | sed -n '/^https:/p')"
if [ -n "${check_url}" ] if [ -n "${check_url}" ]
then then
tmp_var="$(wget "${wget_parm}" --timeout="${adb_maxtime}" --tries=1 --output-document=- "${url}" 2>/dev/null)"
tmp_var="$(wget ${wget_parm} --timeout="${adb_maxtime}" --tries=1 --output-document=- "${url}" 2>/dev/null)"
rc=${?} rc=${?}
else else
tmp_var="$(curl "${curl_parm}" --max-time "${adb_maxtime}" "${url}" 2>/dev/null)"
tmp_var="$(curl ${curl_parm} --max-time "${adb_maxtime}" "${url}" 2>/dev/null)"
rc=${?} rc=${?}
fi fi
@ -143,7 +144,7 @@ do
then then
rm -f "${shalla_file}" >/dev/null 2>&1 rm -f "${shalla_file}" >/dev/null 2>&1
fi fi
unset tmp_var
unset tmp_var 2>/dev/null
elif [ $((rc)) -eq 0 ] && [ -z "${tmp_var}" ] elif [ $((rc)) -eq 0 ] && [ -z "${tmp_var}" ]
then then
f_log "empty source download finished (${url})" f_log "empty source download finished (${url})"
@ -157,11 +158,11 @@ done
# and finally rewrite ad/abuse domain information to dnsmasq file # and finally rewrite ad/abuse domain information to dnsmasq file
# #
> "${adb_dnsfile}" > "${adb_dnsfile}"
grep -vxf "${adb_whitelist}" < "${adb_tmpfile}" 2>/dev/null | sort -u 2>/dev/null | eval "${adb_dnsformat}" 2>/dev/null >> "${adb_dnsfile}" 2>/dev/null
grep -vxf "${adb_whitelist}" < "${adb_tmpfile}" 2>/dev/null | sort -u 2>/dev/null | eval "${adb_dnsformat}" 2>/dev/null >> "${adb_dnsfile}"
rc=${?} rc=${?}
if [ $((rc)) -eq 0 ] if [ $((rc)) -eq 0 ]
then then
unset adb_tmpfile
rm -f "${adb_tmpfile}" >/dev/null 2>&1
f_log "domain merging finished" f_log "domain merging finished"
else else
f_log "domain merging failed" "${rc}" f_log "domain merging failed" "${rc}"


Loading…
Cancel
Save