|
@ -276,7 +276,7 @@ f_envcheck() |
|
|
query_ok="false" |
|
|
query_ok="false" |
|
|
if [ -s "${query_pid}" ] |
|
|
if [ -s "${query_pid}" ] |
|
|
then |
|
|
then |
|
|
kill -9 $(< "${query_pid}") 2>/dev/null |
|
|
|
|
|
|
|
|
kill -9 $(cat "${query_pid}") 2>/dev/null |
|
|
> "${query_pid}" |
|
|
> "${query_pid}" |
|
|
/usr/bin/logger -t "adblock[${pid}]" "info: remove old dns query log background process" |
|
|
/usr/bin/logger -t "adblock[${pid}]" "info: remove old dns query log background process" |
|
|
fi |
|
|
fi |
|
@ -392,14 +392,14 @@ f_remove() |
|
|
query_date="$(date "+%Y%m%d")" |
|
|
query_date="$(date "+%Y%m%d")" |
|
|
if [ -s "${query_pid}" ] && [ ! -f "${adb_queryfile}.${query_date}" ] |
|
|
if [ -s "${query_pid}" ] && [ ! -f "${adb_queryfile}.${query_date}" ] |
|
|
then |
|
|
then |
|
|
kill -9 $(< "${query_pid}") 2>/dev/null |
|
|
|
|
|
|
|
|
kill -9 $(cat "${query_pid}") 2>/dev/null |
|
|
> "${query_pid}" |
|
|
> "${query_pid}" |
|
|
find "${adb_backupdir}" -maxdepth 1 -type f -mtime +${adb_queryhistory} -name "${query_name}.*" -exec rm -f {} \; 2>/dev/null |
|
|
find "${adb_backupdir}" -maxdepth 1 -type f -mtime +${adb_queryhistory} -name "${query_name}.*" -exec rm -f {} \; 2>/dev/null |
|
|
/usr/bin/logger -t "adblock[${pid}]" "info: remove old dns query log background process and do logfile housekeeping" |
|
|
/usr/bin/logger -t "adblock[${pid}]" "info: remove old dns query log background process and do logfile housekeeping" |
|
|
fi |
|
|
fi |
|
|
if [ ! -s "${query_pid}" ] |
|
|
if [ ! -s "${query_pid}" ] |
|
|
then |
|
|
then |
|
|
( logread -f 2>/dev/null & printf -n "$!" > "${query_pid}" ) | egrep -o "(query\[A\].*)|([a-z0-9\.\-]* is ${query_ip}$)" >> "${adb_queryfile}.${query_date}" & |
|
|
|
|
|
|
|
|
( logread -f 2>/dev/null & printf "$!" > "${query_pid}" ) | egrep -o "(query\[A\].*)|([a-z0-9\.\-]* is ${query_ip}$)" >> "${adb_queryfile}.${query_date}" & |
|
|
/usr/bin/logger -t "adblock[${pid}]" "info: start new domain query log background process" |
|
|
/usr/bin/logger -t "adblock[${pid}]" "info: start new domain query log background process" |
|
|
fi |
|
|
fi |
|
|
fi |
|
|
fi |
|
@ -423,11 +423,11 @@ f_restore() |
|
|
then |
|
|
then |
|
|
cp -f "${adb_backupfile}" "${adb_dnsfile}" 2>/dev/null |
|
|
cp -f "${adb_backupfile}" "${adb_dnsfile}" 2>/dev/null |
|
|
/usr/bin/logger -t "adblock[${pid}]" "error: ${restore_msg}, adlist backup restored" |
|
|
/usr/bin/logger -t "adblock[${pid}]" "error: ${restore_msg}, adlist backup restored" |
|
|
printf "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: ${restore_msg}, adlist backup restored" >> "${adb_logfile}" |
|
|
|
|
|
|
|
|
printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: ${restore_msg}, adlist backup restored" >> "${adb_logfile}" |
|
|
else |
|
|
else |
|
|
> "${adb_dnsfile}" |
|
|
> "${adb_dnsfile}" |
|
|
/usr/bin/logger -t "adblock[${pid}]" "error: ${restore_msg}, empty adlist generated" |
|
|
/usr/bin/logger -t "adblock[${pid}]" "error: ${restore_msg}, empty adlist generated" |
|
|
printf "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: ${restore_msg}, empty adlist generated" >> "${adb_logfile}" |
|
|
|
|
|
|
|
|
printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: ${restore_msg}, empty adlist generated" >> "${adb_logfile}" |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
# restart dnsmasq |
|
|
# restart dnsmasq |
|
@ -455,7 +455,7 @@ f_wancheck() |
|
|
do |
|
|
do |
|
|
if [ -d "/sys/class/net/${dev}" ] |
|
|
if [ -d "/sys/class/net/${dev}" ] |
|
|
then |
|
|
then |
|
|
dev_out=$(< /sys/class/net/${dev}/operstate 2>/dev/null) |
|
|
|
|
|
|
|
|
dev_out="$(cat /sys/class/net/${dev}/operstate 2>/dev/null)" |
|
|
if [ "${dev_out}" = "up" ] |
|
|
if [ "${dev_out}" = "up" ] |
|
|
then |
|
|
then |
|
|
/usr/bin/logger -t "adblock[${pid}]" "info: get wan/update interface: ${dev}, after ${cnt} loops" |
|
|
/usr/bin/logger -t "adblock[${pid}]" "info: get wan/update interface: ${dev}, after ${cnt} loops" |
|
@ -464,8 +464,9 @@ f_wancheck() |
|
|
fi |
|
|
fi |
|
|
if [ $((cnt)) -eq $((max_cnt)) ] |
|
|
if [ $((cnt)) -eq $((max_cnt)) ] |
|
|
then |
|
|
then |
|
|
|
|
|
wan_ok="false" |
|
|
/usr/bin/logger -t "adblock[${pid}]" "error: no wan/update interface(s) found (${adb_wandev})" |
|
|
/usr/bin/logger -t "adblock[${pid}]" "error: no wan/update interface(s) found (${adb_wandev})" |
|
|
printf "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: no wan/update interface(s) found (${adb_wandev})" >> "${adb_logfile}" |
|
|
|
|
|
|
|
|
printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: no wan/update interface(s) found (${adb_wandev})" >> "${adb_logfile}" |
|
|
restore_msg="no wan/update interface(s)" |
|
|
restore_msg="no wan/update interface(s)" |
|
|
f_restore |
|
|
f_restore |
|
|
fi |
|
|
fi |
|
@ -506,7 +507,7 @@ f_ntpcheck() |
|
|
then |
|
|
then |
|
|
ntp_ok="false" |
|
|
ntp_ok="false" |
|
|
/usr/bin/logger -t "adblock[${pid}]" "error: ntp time sync failed (${adb_ntpsrv})" |
|
|
/usr/bin/logger -t "adblock[${pid}]" "error: ntp time sync failed (${adb_ntpsrv})" |
|
|
printf "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: ntp time sync failed (${adb_ntpsrv})" >> "${adb_logfile}" |
|
|
|
|
|
|
|
|
printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") - error: ntp time sync failed (${adb_ntpsrv})" >> "${adb_logfile}" |
|
|
restore_msg="time sync failed" |
|
|
restore_msg="time sync failed" |
|
|
f_restore |
|
|
f_restore |
|
|
fi |
|
|
fi |
|
|