#
LC_ALL=C
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
-adb_ver="2.6.2"
+adb_ver="2.6.3"
adb_sysver="$(ubus -S call system board | jsonfilter -e '@.release.description')"
adb_enabled=1
adb_debug=0
adb_dnslist="dnsmasq unbound"
adb_dnsprefix="adb_list"
adb_rtfile="/tmp/adb_runtime.json"
+adb_sources=""
+adb_src_cat_shalla=""
+adb_action="${1}"
# f_envload: load adblock environment
#
sleep 1
cnt=$((cnt+1))
done
- if [ -z "${adb_dns}" ]
- then
- f_log "error" "no active/supported DNS backend found"
- fi
# parse global section by callback
#
config_load adblock
config_foreach parse_config source
+ if [ -z "${adb_dns}" ] || [ -z "${adb_dnsformat}" ] || [ ! -x "$(command -v ${adb_dns})" ] || [ ! -d "${adb_dnsdir}" ]
+ then
+ f_log "error" "no active/supported DNS backend found"
+ fi
+
# force dns to local resolver
#
if [ ${adb_forcedns} -eq 1 ] && [ -z "$(uci -q get firewall.adblock_dns)" ]
if [ -n "$(uci -q changes firewall)" ]
then
uci -q commit firewall
- if [ $(/etc/init.d/firewall enabled; printf ${?}) -eq 0 ]
+ if [ $(/etc/init.d/firewall enabled; printf "%u" ${?}) -eq 0 ]
then
/etc/init.d/firewall reload >/dev/null 2>&1
fi
json_get_keys keylist
for key in ${keylist}
do
- json_get_var value ${key}
+ json_get_var value "${key}"
printf " %-15s : %s\n" "${key}" "${value}"
done
fi
mem_total="$(awk '$1 ~ /^MemTotal/ {printf $2}' "/proc/meminfo" 2>/dev/null)"
f_log "info " "start adblock processing ..."
+ f_log "debug" "action: ${adb_action}, backup: ${adb_backup}, dns: ${adb_dns}, fetch: ${adb_fetchinfo}, memory: ${mem_total}, force srt/dns: ${adb_forcesrt}/${adb_forcedns}"
> "${adb_rtfile}"
for src_name in ${adb_sources}
do
# basic pre-checks
#
+ f_log "debug" "name: ${src_name}, enabled: ${enabled}, url: ${url}, rset: ${src_rset}"
if [ "${enabled}" != "1" ] || [ -z "${url}" ] || [ -z "${src_rset}" ]
then
f_list remove
# download block list
#
- f_log "debug" "name: ${src_name}, enabled: ${enabled}, backup: ${adb_backup}, dns: ${adb_dns}, fetch: ${adb_fetchinfo}, memory: ${mem_total}, force srt/dns: ${adb_forcesrt}/${adb_forcedns}"
if [ "${src_name}" = "blacklist" ]
then
cat "${url}" 2>/dev/null > "${adb_tmpload}"
then
for category in ${adb_src_cat_shalla}
do
- tar -xOzf "${shalla_archive}" BL/${category}/domains >> "${adb_tmpload}"
+ tar -xOzf "${shalla_archive}" "BL/${category}/domains" >> "${adb_tmpload}"
adb_rc=${?}
if [ ${adb_rc} -ne 0 ]
then
then
grep -vf "${adb_tmpdir}/tmp.whitelist" "${adb_tmpfile}" 2>/dev/null | eval "${adb_dnsformat}" > "${adb_dnsfile}"
else
- cat "${adb_tmpfile}" 2>/dev/null | eval "${adb_dnsformat}" > "${adb_dnsfile}"
+ eval "${adb_dnsformat}" "${adb_tmpfile}" > "${adb_dnsfile}"
fi
adb_rc=${?}
if [ ${adb_rc} -ne 0 ]
# handle different adblock actions
#
f_envload
-case "${1}" in
+case "${adb_action}" in
stop)
f_rmtemp
f_rmdns