Browse Source

Merge pull request #10446 from dibdot/adblock

adblock: update 3.8.8
lilik-openwrt-22.03
Dirk Brenken 5 years ago
committed by GitHub
parent
commit
af504f1288
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 21 deletions
  1. +1
    -1
      net/adblock/Makefile
  2. +20
    -13
      net/adblock/files/adblock.mail
  3. +12
    -2
      net/adblock/files/adblock.service
  4. +18
    -5
      net/adblock/files/adblock.sh

+ 1
- 1
net/adblock/Makefile View File

@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=adblock
PKG_VERSION:=3.8.7
PKG_VERSION:=3.8.8
PKG_RELEASE:=1
PKG_LICENSE:=GPL-3.0-or-later
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>


+ 20
- 13
net/adblock/files/adblock.mail View File

@ -21,6 +21,8 @@ then
fi
adb_ver="${1}"
adb_mail="$(command -v msmtp)"
adb_logger="$(command -v logger)"
adb_logread="$(command -v logread)"
adb_rc=1
if [ "${adb_debug}" -eq 1 ]
@ -28,13 +30,6 @@ then
debug="--debug"
fi
# mail header & receiver check
#
if [ -z "${adb_mreceiver}" ]
then
logger -p "err" -t "adblock-${adb_ver}[${$}]" "please set the mail receiver with the 'adb_mreceiver' option"
exit ${adb_rc}
fi
adb_mhead="From: ${adb_msender}\\nTo: ${adb_mreceiver}\\nSubject: ${adb_mtopic}\\nReply-to: ${adb_msender}\\nMime-Version: 1.0\\nContent-Type: text/html\\nContent-Disposition: inline\\n\\n"
# info preparation
@ -44,8 +39,9 @@ adb_info="$(/etc/init.d/adblock status 2>/dev/null)"
if [ -f "/var/log/messages" ]
then
log_info="$(awk '/adblock-/{NR=1;max=79;if(length($0)>max+1)while($0){if(NR==1){print substr($0,1,max),"&#8629;"} else {print " ",substr($0,1,max)}{$0=substr($0,max+1);NR=NR+1}}else print}' /var/log/messages)"
else
log_info="$(logread -e "adblock-" | awk '{NR=1;max=79;if(length($0)>max+1)while($0){if(NR==1){print substr($0,1,max),"&#8629;"} else {print " ",substr($0,1,max)}{$0=substr($0,max+1);NR=NR+1}}else print}')"
elif [ -x "${adb_logread}" ]
then
log_info="$("${adb_logread}" -e "adblock-" | awk '{NR=1;max=79;if(length($0)>max+1)while($0){if(NR==1){print substr($0,1,max),"&#8629;"} else {print " ",substr($0,1,max)}{$0=substr($0,max+1);NR=NR+1}}else print}')"
fi
# mail body
@ -58,13 +54,24 @@ adb_mtext="${adb_mtext}</pre></body></html>"
# send mail
#
if [ -x "${adb_mail}" ]
if [ -x "${adb_mail}" ] && [ -n "${adb_mreceiver}" ]
then
printf "%b" "${adb_mhead}${adb_mtext}" 2>/dev/null | "${adb_mail}" ${debug} -a "${adb_mprofile}" "${adb_mreceiver}" >/dev/null 2>&1
adb_rc=${?}
logger -p "info" -t "adblock-${adb_ver}[${$}]" "mail sent to '${adb_mreceiver}' with rc '${adb_rc}'"
class="info"
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
logger -p "err" -t "adblock-${adb_ver}[${$}]" "msmtp mail daemon not found"
class="err"
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
exit ${adb_rc}

+ 12
- 2
net/adblock/files/adblock.service View File

@ -16,12 +16,22 @@ then
fi
adb_ver="${1}"
adb_ubus="$(command -v ubus)"
adb_logger="$(command -v logger)"
if [ -x "${adb_ubus}" ] && [ -n "${adb_dns}" ]
then
logger -p "info" -t "adblock-${adb_ver}[${$}]" "ubus/adblock service started"
"${adb_ubus}" -S -M r -m invoke monitor | \
{ 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
logger -p "err" -t "adblock-${adb_ver}[${$}]" "can't start ubus/adblock service"
class="err"
log_msg="can't start ubus/adblock service"
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

+ 18
- 5
net/adblock/files/adblock.sh View File

@ -13,7 +13,7 @@
#
LC_ALL=C
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
adb_ver="3.8.7"
adb_ver="3.8.8"
adb_basever=""
adb_enabled=0
adb_debug=0
@ -43,6 +43,7 @@ adb_repdir="/tmp"
adb_reputil="$(command -v tcpdump)"
adb_repchunkcnt="5"
adb_repchunksize="1"
adb_logger="$(command -v logger)"
adb_action="${1:-"start"}"
adb_pidfile="/var/run/adblock.pid"
adb_ubusservice="/etc/adblock/adblock.service"
@ -105,6 +106,7 @@ f_load()
if [ -z "${adb_basever}" ] || [ "${adb_ver%.*}" != "${adb_basever}" ]
then
f_log "info" "your adblock config seems to be too old, please update your config with the '--force-maintainer' opkg option"
f_rmtemp
exit 0
fi
@ -916,13 +918,24 @@ f_log()
if [ -n "${log_msg}" ] && { [ "${class}" != "debug" ] || [ "${adb_debug}" -eq 1 ]; }
then
logger -p "${class}" -t "adblock-${adb_ver}[${$}]" "${log_msg}"
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 [ "${class}" = "err" ]
then
f_rmdns
f_bgserv "stop"
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'"
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
fi
fi
@ -934,11 +947,11 @@ f_bgserv()
{
local bg_pid status="${1}"
bg_pid="$(pgrep -f "^/bin/sh ${adb_ubusservice}|^/bin/ubus -S -M r -m invoke monitor|^grep -qF \"method\":\"set\",\"data\":\\{\"name\":\"${adb_dns}\"" | awk '{ORS=" "; print $1}')"
bg_pid="$(pgrep -f "^/bin/sh ${adb_ubusservice}.*|^/bin/ubus -S -M r -m invoke monitor|^grep -qF \"method\":\"set\",\"data\":\\{\"name\":\"${adb_dns}\"" | awk '{ORS=" "; print $1}')"
if [ -z "${bg_pid}" ] && [ "${status}" = "start" ] \
&& [ -x "${adb_ubusservice}" ] && [ "${adb_dnsfilereset}" = "true" ]
then
( "${adb_ubusservice}" "${adb_ver}" &)
( "${adb_ubusservice}" "${adb_ver}" & )
elif [ -n "${bg_pid}" ] && [ "${status}" = "stop" ]
then
kill -HUP "${bg_pid}" 2>/dev/null


Loading…
Cancel
Save