commit
5ed3eb26b3
3 changed files with 40 additions and 27 deletions
|
@ -6,8 +6,8 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=adblock
|
PKG_NAME:=adblock
|
||||||
PKG_VERSION:=3.8.5
|
PKG_VERSION:=3.8.6
|
||||||
PKG_RELEASE:=2
|
PKG_RELEASE:=1
|
||||||
PKG_LICENSE:=GPL-3.0-or-later
|
PKG_LICENSE:=GPL-3.0-or-later
|
||||||
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
|
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#
|
#
|
||||||
LC_ALL=C
|
LC_ALL=C
|
||||||
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
adb_ver="3.8.5"
|
adb_ver="3.8.6"
|
||||||
adb_basever=""
|
adb_basever=""
|
||||||
adb_enabled=0
|
adb_enabled=0
|
||||||
adb_debug=0
|
adb_debug=0
|
||||||
|
@ -164,6 +164,7 @@ f_load()
|
||||||
f_extconf
|
f_extconf
|
||||||
f_temp
|
f_temp
|
||||||
f_rmdns
|
f_rmdns
|
||||||
|
f_bgserv "stop"
|
||||||
f_jsnup "disabled"
|
f_jsnup "disabled"
|
||||||
f_log "info" "adblock is currently disabled, please set the config option 'adb_enabled' to '1' to use this service"
|
f_log "info" "adblock is currently disabled, please set the config option 'adb_enabled' to '1' to use this service"
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -181,6 +182,8 @@ f_load()
|
||||||
sleep "${adb_triggerdelay}"
|
sleep "${adb_triggerdelay}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "${adb_action}" != "stop" ]
|
||||||
|
then
|
||||||
while [ "${cnt}" -le 30 ]
|
while [ "${cnt}" -le 30 ]
|
||||||
do
|
do
|
||||||
dns_up="$(ubus -S call service list "{\"name\":\"${adb_dns}\"}" 2>/dev/null | jsonfilter -l1 -e "@[\"${adb_dns}\"].instances.*.running" 2>/dev/null)"
|
dns_up="$(ubus -S call service list "{\"name\":\"${adb_dns}\"}" 2>/dev/null | jsonfilter -l1 -e "@[\"${adb_dns}\"].instances.*.running" 2>/dev/null)"
|
||||||
|
@ -194,10 +197,11 @@ f_load()
|
||||||
|
|
||||||
if [ "${dns_up}" != "true" ] || [ -z "${adb_dns}" ] || [ ! -x "$(command -v "${adb_dns}")" ]
|
if [ "${dns_up}" != "true" ] || [ -z "${adb_dns}" ] || [ ! -x "$(command -v "${adb_dns}")" ]
|
||||||
then
|
then
|
||||||
f_log "err" "'${adb_dns}' not running or executable"
|
f_log "err" "dns backend '${adb_dns}' not running or executable"
|
||||||
elif [ ! -d "${adb_dnsdir}" ]
|
elif [ ! -d "${adb_dnsdir}" ]
|
||||||
then
|
then
|
||||||
f_log "err" "'${adb_dnsdir}' dns backend directory not found"
|
f_log "err" "dns backend directory '${adb_dnsdir}' not found"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# inotify check
|
# inotify check
|
||||||
|
@ -208,7 +212,7 @@ f_load()
|
||||||
then
|
then
|
||||||
adb_dnsfilereset="false"
|
adb_dnsfilereset="false"
|
||||||
fi
|
fi
|
||||||
f_log "info" "Inotify is enabled for '${adb_dns}', adblock restart and file reset will be disabled"
|
f_log "info" "inotify is enabled for '${adb_dns}', adblock restart and file reset will be disabled"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +230,7 @@ f_env()
|
||||||
#
|
#
|
||||||
if [ ! -d "${adb_backupdir}" ]
|
if [ ! -d "${adb_backupdir}" ]
|
||||||
then
|
then
|
||||||
f_log "err" "the backup directory '${adb_backupdir}' does not exist/is not mounted yet, please create the directory or raise the 'adb_triggerdelay' to defer the adblock start"
|
f_log "err" "backup directory '${adb_backupdir}' does not exist/is not mounted yet, please create the directory or raise the 'adb_triggerdelay' to defer the adblock start"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check fetch utility
|
# check fetch utility
|
||||||
|
@ -304,15 +308,23 @@ f_rmtemp()
|
||||||
#
|
#
|
||||||
f_rmdns()
|
f_rmdns()
|
||||||
{
|
{
|
||||||
if [ -n "${adb_dns}" ]
|
local status dns_status rc
|
||||||
|
|
||||||
|
status="$(ubus -S call service list '{"name":"adblock"}' 2>/dev/null | jsonfilter -l1 -e '@["adblock"].instances.*.running' 2>/dev/null)"
|
||||||
|
if [ -n "${adb_dns}" ] && [ -n "${status}" ]
|
||||||
then
|
then
|
||||||
|
dns_status="$(ubus -S call service list "{\"name\":\"${adb_dns}\"}" 2>/dev/null | jsonfilter -l1 -e "@[\"${adb_dns}\"].instances.*.running" 2>/dev/null)"
|
||||||
printf "%s\\n" "${adb_dnsheader}" > "${adb_dnsdir}/${adb_dnsfile}"
|
printf "%s\\n" "${adb_dnsheader}" > "${adb_dnsdir}/${adb_dnsfile}"
|
||||||
> "${adb_rtfile}"
|
> "${adb_rtfile}"
|
||||||
rm -f "${adb_backupdir}/${adb_dnsprefix}"*.gz
|
rm "${adb_backupdir}/${adb_dnsprefix}".*.gz 2>/dev/null
|
||||||
|
rc="${?}"
|
||||||
|
if [ "${rc}" -eq 0 ] && [ -n "${dns_status}" ]
|
||||||
|
then
|
||||||
f_dnsup 4
|
f_dnsup 4
|
||||||
f_rmtemp
|
|
||||||
fi
|
fi
|
||||||
f_log "debug" "f_rmdns ::: dns: ${adb_dns}, dns_dir: ${adb_dnsdir}, dns_file: ${adb_dnsfile}, rt_file: ${adb_rtfile}, backup_dir: ${adb_backupdir}"
|
fi
|
||||||
|
f_rmtemp
|
||||||
|
f_log "debug" "f_rmdns ::: status: ${status:-"-"}, dns_status: ${dns_status:-"-"}, rc: ${rc:-"-"}, dns: ${adb_dns}, dns_dir: ${adb_dnsdir}, dns_file: ${adb_dnsfile}, rt_file: ${adb_rtfile}, backup_dir: ${adb_backupdir}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# commit uci changes
|
# commit uci changes
|
||||||
|
@ -908,6 +920,7 @@ f_log()
|
||||||
if [ "${class}" = "err" ]
|
if [ "${class}" = "err" ]
|
||||||
then
|
then
|
||||||
f_rmdns
|
f_rmdns
|
||||||
|
f_bgserv "stop"
|
||||||
f_jsnup "error"
|
f_jsnup "error"
|
||||||
logger -p "${class}" -t "adblock-${adb_ver}[${$}]" "Please also check 'https://github.com/openwrt/packages/blob/master/net/adblock/files/README.md'"
|
logger -p "${class}" -t "adblock-${adb_ver}[${$}]" "Please also check 'https://github.com/openwrt/packages/blob/master/net/adblock/files/README.md'"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in a new issue