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>
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
}
# 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
#
#
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
}
#############################################
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
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
}
################################################
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}
}
# 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
#
# start logging
#
-f_log "domain adblock processing started (${adb_version})"
+f_log "domain adblock processing started (${adb_version}, ${openwrt_version})"
# load environment
#
#
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
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}"
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
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})"
# 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}"