Browse Source

adblock: bugfix release

* fix download parms
* fix tmp vars
* other small fixes

Signed-off-by: Dirk Brenken <dirk@brenken.org>
lilik-openwrt-22.03
Dirk Brenken 9 years ago
parent
commit
2d40930fa0
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
PKG_NAME:=adblock
PKG_VERSION:=0.22.0
PKG_VERSION:=0.22.1
PKG_RELEASE:=1
PKG_LICENSE:=GPL-3.0+
PKG_MAINTAINER:=Dirk Brenken <dirk@brenken.org>


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

@ -138,13 +138,13 @@ f_envparse()
done
elif [ "${config}" = "wancheck" ]
then
unset adb_wandev
unset adb_wandev 2>/dev/null
elif [ "${config}" = "ntpcheck" ]
then
unset adb_ntpsrv
unset adb_ntpsrv 2>/dev/null
elif [ "${config}" = "shalla" ]
then
unset adb_cat_shalla
unset adb_cat_shalla 2>/dev/null
fi
}
@ -157,7 +157,7 @@ f_envparse()
# set temp variables and counter
#
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
#
@ -173,14 +173,6 @@ f_envparse()
#
adb_dnsfile="/tmp/dnsmasq.d/adlist.conf"
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 -")"
if [ -z "${check}" ]
then
curl_parm="--insecure"
wget_parm="--no-check-certificate"
curl_parm="-q --insecure"
wget_parm="--no-config --no-check-certificate"
else
unset curl_parm
unset wget_parm
curl_parm="-q"
wget_parm="--no-config"
fi
# check total and swap memory
@ -424,6 +416,16 @@ f_envcheck()
f_remove
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
fi
if [ -d "${adb_tmpdir}" ]
then
then
rm -rf "${adb_tmpdir}" >/dev/null 2>&1
fi
f_log "domain adblock processing finished (${adb_version})"
f_log "domain adblock processing finished (${adb_version}, ${openwrt_version})"
exit ${rc}
}


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

@ -25,12 +25,13 @@
# 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=${$}
adb_scriptdir="${0%/*}"
openwrt_version="$(cat /etc/openwrt_version 2>/dev/null)"
# 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
#
f_log "domain adblock processing started (${adb_version})"
f_log "domain adblock processing started (${adb_version}, ${openwrt_version})"
# load environment
#
@ -75,7 +76,7 @@ then
#
shalla_archive="${adb_tmpdir}/shallalist.tar.gz"
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=${?}
if [ $((rc)) -eq 0 ]
then
@ -96,7 +97,7 @@ then
then
if [ -r "${adb_tmpdir}/BL/${category}/domains" ]
then
cat "${adb_tmpdir}/BL/${category}/domains" >> "${shalla_file}" 2>/dev/null
cat "${adb_tmpdir}/BL/${category}/domains" 2>/dev/null >> "${shalla_file}"
fi
else
f_log "shallalist archive extraction failed (${category})" "${rc}"
@ -124,10 +125,10 @@ do
check_url="$(printf "${url}" | sed -n '/^https:/p')"
if [ -n "${check_url}" ]
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=${?}
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=${?}
fi
@ -143,7 +144,7 @@ do
then
rm -f "${shalla_file}" >/dev/null 2>&1
fi
unset tmp_var
unset tmp_var 2>/dev/null
elif [ $((rc)) -eq 0 ] && [ -z "${tmp_var}" ]
then
f_log "empty source download finished (${url})"
@ -157,11 +158,11 @@ done
# and finally rewrite ad/abuse domain information to dnsmasq file
#
> "${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=${?}
if [ $((rc)) -eq 0 ]
then
unset adb_tmpfile
rm -f "${adb_tmpfile}" >/dev/null 2>&1
f_log "domain merging finished"
else
f_log "domain merging failed" "${rc}"


Loading…
Cancel
Save