adblock: update 3.8.9
* more startup tweaks * re-use f_log function in helper scripts * small fixes / polish up for forthcoming 19.07 release Signed-off-by: Dirk Brenken <dev@brenken.org>
This commit is contained in:
parent
9c82e9e282
commit
2c3cb6f1d1
|
@ -6,7 +6,7 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=adblock
|
PKG_NAME:=adblock
|
||||||
PKG_VERSION:=3.8.8
|
PKG_VERSION:=3.8.9
|
||||||
PKG_RELEASE:=1
|
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>
|
||||||
|
|
|
@ -15,14 +15,15 @@ adb_init="/etc/init.d/adblock"
|
||||||
adb_script="/usr/bin/adblock.sh"
|
adb_script="/usr/bin/adblock.sh"
|
||||||
adb_pidfile="/var/run/adblock.pid"
|
adb_pidfile="/var/run/adblock.pid"
|
||||||
|
|
||||||
if [ -s "${adb_pidfile}" ] && [ "${action}" != "help" ] && [ "${action}" != "status" ]
|
if [ -s "${adb_pidfile}" ] && \
|
||||||
|
[ "${action}" != "help" ] && [ "${action}" != "status" ] && [ "${action}" != "boot" ]
|
||||||
then
|
then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
boot()
|
boot()
|
||||||
{
|
{
|
||||||
adb_boot=1
|
[ -s "${adb_pidfile}" ] && > "${adb_pidfile}"
|
||||||
rc_procd start_service
|
rc_procd start_service
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,19 +31,17 @@ start_service()
|
||||||
{
|
{
|
||||||
if [ "$("${adb_init}" enabled; printf "%u" ${?})" -eq 0 ]
|
if [ "$("${adb_init}" enabled; printf "%u" ${?})" -eq 0 ]
|
||||||
then
|
then
|
||||||
if [ -n "${adb_boot}" ]
|
if [ "${action}" = "boot" ]
|
||||||
then
|
then
|
||||||
local trigger="$(uci_get adblock global adb_trigger)"
|
if [ "$(uci_get adblock global adb_trigger)" != "timed" ]
|
||||||
if [ "${trigger}" != "timed" ]
|
|
||||||
then
|
then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
local nice="$(uci_get adblock extra adb_nice "0")"
|
|
||||||
procd_open_instance "adblock"
|
procd_open_instance "adblock"
|
||||||
procd_set_param command "${adb_script}" "${@}"
|
procd_set_param command "${adb_script}" "${@}"
|
||||||
procd_set_param pidfile "${adb_pidfile}"
|
procd_set_param pidfile "${adb_pidfile}"
|
||||||
procd_set_param nice "${nice}"
|
procd_set_param nice "$(uci_get adblock extra adb_nice "0")"
|
||||||
procd_set_param stdout 1
|
procd_set_param stdout 1
|
||||||
procd_set_param stderr 1
|
procd_set_param stderr 1
|
||||||
procd_close_instance
|
procd_close_instance
|
||||||
|
|
|
@ -25,6 +25,24 @@ adb_logger="$(command -v logger)"
|
||||||
adb_logread="$(command -v logread)"
|
adb_logread="$(command -v logread)"
|
||||||
adb_rc=1
|
adb_rc=1
|
||||||
|
|
||||||
|
f_log()
|
||||||
|
{
|
||||||
|
local class="${1}" log_msg="${2}"
|
||||||
|
|
||||||
|
if [ -x "${adb_logger}" ]
|
||||||
|
then
|
||||||
|
"${adb_logger}" -p "${class}" -t "adblock-${adb_ver}[${$}]" "${log_msg}"
|
||||||
|
else
|
||||||
|
printf "%s %s %s\\n" "${class}" "adblock-${adb_ver}[${$}]" "${log_msg}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "${adb_mreceiver}" ]
|
||||||
|
then
|
||||||
|
f_log "err" "please set the mail receiver with the 'adb_mreceiver' option"
|
||||||
|
exit ${adb_rc}
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "${adb_debug}" -eq 1 ]
|
if [ "${adb_debug}" -eq 1 ]
|
||||||
then
|
then
|
||||||
debug="--debug"
|
debug="--debug"
|
||||||
|
@ -58,20 +76,8 @@ if [ -x "${adb_mail}" ] && [ -n "${adb_mreceiver}" ]
|
||||||
then
|
then
|
||||||
printf "%b" "${adb_mhead}${adb_mtext}" 2>/dev/null | "${adb_mail}" ${debug} -a "${adb_mprofile}" "${adb_mreceiver}" >/dev/null 2>&1
|
printf "%b" "${adb_mhead}${adb_mtext}" 2>/dev/null | "${adb_mail}" ${debug} -a "${adb_mprofile}" "${adb_mreceiver}" >/dev/null 2>&1
|
||||||
adb_rc=${?}
|
adb_rc=${?}
|
||||||
class="info"
|
f_log "info" "mail sent to '${adb_mreceiver}' with rc '${adb_rc}'"
|
||||||
log_msg="mail sent to '${adb_mreceiver}' with rc '${adb_rc}'"
|
|
||||||
elif [ -z "${adb_mreceiver}" ]
|
|
||||||
then
|
|
||||||
class="err"
|
|
||||||
log_msg="please set the mail receiver with the 'adb_mreceiver' option"
|
|
||||||
else
|
else
|
||||||
class="err"
|
f_log "err" "msmtp mail daemon not found"
|
||||||
log_msg="msmtp mail daemon not found"
|
|
||||||
fi
|
|
||||||
if [ -x "${adb_logger}" ]
|
|
||||||
then
|
|
||||||
"${adb_logger}" -p "${class}" -t "adblock-${adb_ver}[${$}]" "${log_msg}"
|
|
||||||
else
|
|
||||||
printf "%s %s %s\\n" "${class}" "adblock-${adb_ver}[${$}]" "${log_msg}"
|
|
||||||
fi
|
fi
|
||||||
exit ${adb_rc}
|
exit ${adb_rc}
|
||||||
|
|
|
@ -18,20 +18,23 @@ adb_ver="${1}"
|
||||||
adb_ubus="$(command -v ubus)"
|
adb_ubus="$(command -v ubus)"
|
||||||
adb_logger="$(command -v logger)"
|
adb_logger="$(command -v logger)"
|
||||||
|
|
||||||
|
f_log()
|
||||||
|
{
|
||||||
|
local class="${1}" log_msg="${2}"
|
||||||
|
|
||||||
|
if [ -x "${adb_logger}" ]
|
||||||
|
then
|
||||||
|
"${adb_logger}" -p "${class}" -t "adblock-${adb_ver}[${$}]" "${log_msg}"
|
||||||
|
else
|
||||||
|
printf "%s %s %s\\n" "${class}" "adblock-${adb_ver}[${$}]" "${log_msg}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [ -x "${adb_ubus}" ] && [ -n "${adb_dns}" ]
|
if [ -x "${adb_ubus}" ] && [ -n "${adb_dns}" ]
|
||||||
then
|
then
|
||||||
|
f_log "info" "ubus/adblock service started"
|
||||||
"${adb_ubus}" -S -M r -m invoke monitor | \
|
"${adb_ubus}" -S -M r -m invoke monitor | \
|
||||||
{ grep -qE "\"method\":\"(set|signal)\",\"data\":\{\"name\":\"${adb_dns}\""; [ $? -eq 0 ] && /etc/init.d/adblock start; }
|
{ grep -qE "\"method\":\"(set|signal)\",\"data\":\{\"name\":\"${adb_dns}\""; [ $? -eq 0 ] && /etc/init.d/adblock start; }
|
||||||
class="info"
|
|
||||||
log_msg="ubus/adblock service started"
|
|
||||||
else
|
else
|
||||||
class="err"
|
f_log "err" "can't start ubus/adblock service"
|
||||||
log_msg="can't start ubus/adblock service"
|
|
||||||
fi
|
fi
|
||||||
if [ -x "${adb_logger}" ]
|
|
||||||
then
|
|
||||||
"${adb_logger}" -p "${class}" -t "adblock-${adb_ver}[${$}]" "${log_msg}"
|
|
||||||
else
|
|
||||||
printf "%s %s %s\\n" "${class}" "adblock-${adb_ver}[${$}]" "${log_msg}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
|
@ -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.8"
|
adb_ver="3.8.9"
|
||||||
adb_basever=""
|
adb_basever=""
|
||||||
adb_enabled=0
|
adb_enabled=0
|
||||||
adb_debug=0
|
adb_debug=0
|
||||||
|
@ -283,13 +283,12 @@ f_temp()
|
||||||
if [ -d "/tmp" ] && [ -z "${adb_tmpdir}" ]
|
if [ -d "/tmp" ] && [ -z "${adb_tmpdir}" ]
|
||||||
then
|
then
|
||||||
adb_tmpdir="$(mktemp -p /tmp -d)"
|
adb_tmpdir="$(mktemp -p /tmp -d)"
|
||||||
adb_tmpload="$(mktemp -p "${adb_tmpdir}" -tu)"
|
|
||||||
adb_tmpfile="$(mktemp -p "${adb_tmpdir}" -tu)"
|
adb_tmpfile="$(mktemp -p "${adb_tmpdir}" -tu)"
|
||||||
elif [ ! -d "/tmp" ]
|
elif [ ! -d "/tmp" ]
|
||||||
then
|
then
|
||||||
f_log "err" "the temp directory '/tmp' does not exist/is not mounted yet, please create the directory or raise the 'adb_triggerdelay' to defer the adblock start"
|
f_log "err" "the temp directory '/tmp' does not exist/is not mounted yet, please create the directory or raise the 'adb_triggerdelay' to defer the adblock start"
|
||||||
fi
|
fi
|
||||||
if [ ! -s "${adb_pidfile}" ]
|
if [ ! -f "${adb_pidfile}" ] || [ ! -s "${adb_pidfile}" ]
|
||||||
then
|
then
|
||||||
printf "%s" "${$}" > "${adb_pidfile}"
|
printf "%s" "${$}" > "${adb_pidfile}"
|
||||||
fi
|
fi
|
||||||
|
@ -929,13 +928,6 @@ f_log()
|
||||||
f_rmdns
|
f_rmdns
|
||||||
f_bgserv "stop"
|
f_bgserv "stop"
|
||||||
f_jsnup "error"
|
f_jsnup "error"
|
||||||
log_msg="Please also check 'https://github.com/openwrt/packages/blob/master/net/adblock/files/README.md'"
|
|
||||||
if [ -x "${adb_logger}" ]
|
|
||||||
then
|
|
||||||
"${adb_logger}" -p "${class}" -t "adblock-${adb_ver}[${$}]" "${log_msg}"
|
|
||||||
else
|
|
||||||
printf "%s %s %s\\n" "${class}" "adblock-${adb_ver}[${$}]" "${log_msg}"
|
|
||||||
fi
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -979,8 +971,8 @@ f_main()
|
||||||
src_url="$(eval printf "%s" \"\$\{adb_src_${src_name}\}\")"
|
src_url="$(eval printf "%s" \"\$\{adb_src_${src_name}\}\")"
|
||||||
src_rset="$(eval printf "%s" \"\$\{adb_src_rset_${src_name}\}\")"
|
src_rset="$(eval printf "%s" \"\$\{adb_src_rset_${src_name}\}\")"
|
||||||
src_cat="$(eval printf "%s" \"\$\{adb_src_cat_${src_name}\}\")"
|
src_cat="$(eval printf "%s" \"\$\{adb_src_cat_${src_name}\}\")"
|
||||||
src_tmpload="${adb_tmpload}.${src_name}"
|
src_tmpload="${adb_tmpfile}.${src_name}.load"
|
||||||
src_tmpfile="${adb_tmpfile}.${src_name}"
|
src_tmpfile="${adb_tmpfile}.${src_name}.file"
|
||||||
src_rc=4
|
src_rc=4
|
||||||
|
|
||||||
# basic pre-checks
|
# basic pre-checks
|
||||||
|
|
Loading…
Reference in New Issue