Merge pull request #22241 from stangri/master-adblock-fast
adblock-fast: better error reporting when nothing to do
This commit is contained in:
commit
002ff0dd11
2 changed files with 30 additions and 23 deletions
|
@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=adblock-fast
|
PKG_NAME:=adblock-fast
|
||||||
PKG_VERSION:=1.0.0
|
PKG_VERSION:=1.0.0
|
||||||
PKG_RELEASE:=3
|
PKG_RELEASE:=4
|
||||||
PKG_MAINTAINER:=Stan Grishin <stangri@melmac.ca>
|
PKG_MAINTAINER:=Stan Grishin <stangri@melmac.ca>
|
||||||
PKG_LICENSE:=GPL-3.0-or-later
|
PKG_LICENSE:=GPL-3.0-or-later
|
||||||
|
|
||||||
|
|
|
@ -152,6 +152,7 @@ get_text() {
|
||||||
errorNoSSLSupport) r="no HTTPS/SSL support on device";;
|
errorNoSSLSupport) r="no HTTPS/SSL support on device";;
|
||||||
errorCreatingDirectory) r="failed to create output/cache/gzip file directory";;
|
errorCreatingDirectory) r="failed to create output/cache/gzip file directory";;
|
||||||
errorDetectingFileType) r="failed to detect format";;
|
errorDetectingFileType) r="failed to detect format";;
|
||||||
|
errorNothingToDo) r="no blocked list URLs nor blocked-domains enabled";;
|
||||||
|
|
||||||
statusNoInstall) r="$serviceName is not installed or not found";;
|
statusNoInstall) r="$serviceName is not installed or not found";;
|
||||||
statusStopped) r="Stopped";;
|
statusStopped) r="Stopped";;
|
||||||
|
@ -273,11 +274,11 @@ append_url() {
|
||||||
local file="$1"
|
local file="$1"
|
||||||
if [ "$(head -1 "$file")" = '[Adblock Plus]' ] || \
|
if [ "$(head -1 "$file")" = '[Adblock Plus]' ] || \
|
||||||
grep -q '^||' "$file"; then
|
grep -q '^||' "$file"; then
|
||||||
echo 'adBlockPlus'
|
echo 'adblockplus'
|
||||||
elif grep -q '^server=' "$file"; then
|
elif grep -q '^server=' "$file"; then
|
||||||
echo 'dnsmasqFile'
|
echo 'dnsmasq'
|
||||||
elif grep -q '^local=' "$file"; then
|
elif grep -q '^local=' "$file"; then
|
||||||
echo 'dnsmasq2File'
|
echo 'dnsmasq2'
|
||||||
elif grep -q '^0.0.0.0' "$file" || grep -q '^127.0.0.1' "$file"; then
|
elif grep -q '^0.0.0.0' "$file" || grep -q '^127.0.0.1' "$file"; then
|
||||||
echo 'hosts'
|
echo 'hosts'
|
||||||
elif [ -n "$(sed "$domainsFilter" "$file" | head -1)" ]; then
|
elif [ -n "$(sed "$domainsFilter" "$file" | head -1)" ]; then
|
||||||
|
@ -287,11 +288,11 @@ append_url() {
|
||||||
# detect_file_type() {
|
# detect_file_type() {
|
||||||
# local file="$1"
|
# local file="$1"
|
||||||
# if [ -n "$(sed "$adBlockPlusFilter" "$file" | head -1)" ]; then
|
# if [ -n "$(sed "$adBlockPlusFilter" "$file" | head -1)" ]; then
|
||||||
# echo 'adBlockPlus'
|
# echo 'adblockplus'
|
||||||
# elif [ -n "$(sed "$dnsmasqFileFilter" "$file" | head -1)" ]; then
|
# elif [ -n "$(sed "$dnsmasqFileFilter" "$file" | head -1)" ]; then
|
||||||
# echo 'dnsmasqFile'
|
# echo 'dnsmasq'
|
||||||
# elif [ -n "$(sed "$dnsmasq2FileFilter" "$file" | head -1)" ]; then
|
# elif [ -n "$(sed "$dnsmasq2FileFilter" "$file" | head -1)" ]; then
|
||||||
# echo 'dnsmasq2File'
|
# echo 'dnsmasq2'
|
||||||
# elif [ -n "$(sed "$hostsFilter" "$file" | head -1)" ]; then
|
# elif [ -n "$(sed "$hostsFilter" "$file" | head -1)" ]; then
|
||||||
# echo 'hosts'
|
# echo 'hosts'
|
||||||
# elif [ -n "$(sed "$domainsFilter" "$file" | head -1)" ]; then
|
# elif [ -n "$(sed "$domainsFilter" "$file" | head -1)" ]; then
|
||||||
|
@ -864,9 +865,9 @@ process_file_url() {
|
||||||
fi
|
fi
|
||||||
format="$(detect_file_type "$R_TMP")"
|
format="$(detect_file_type "$R_TMP")"
|
||||||
case "$format" in
|
case "$format" in
|
||||||
adBlockPlus) filter="$adBlockPlusFilter";;
|
adblockplus) filter="$adBlockPlusFilter";;
|
||||||
dnsmasqFile) filter="$dnsmasqFileFilter";;
|
dnsmasq) filter="$dnsmasqFileFilter";;
|
||||||
dnsmasq2File) filter="$dnsmasq2FileFilter";;
|
dnsmasq2) filter="$dnsmasq2FileFilter";;
|
||||||
domains) filter="$domainsFilter";;
|
domains) filter="$domainsFilter";;
|
||||||
hosts) filter="$hostsFilter";;
|
hosts) filter="$hostsFilter";;
|
||||||
*)
|
*)
|
||||||
|
@ -1389,21 +1390,27 @@ adb_start() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$action" = 'download' ]; then
|
if [ "$action" = 'download' ]; then
|
||||||
if [ -s "$outputFile" ] || cache 'test' || cache 'test_gzip'; then
|
if [ -z "$blocked_url" ] && [ -z "$blocked_domain" ]; then
|
||||||
output 0 "Force-reloading $serviceName... "
|
json set status "statusFail"
|
||||||
output 3 "Force-reloading $serviceName...\\n"
|
json add error "errorNothingToDo"
|
||||||
json set status "statusForceReloading"
|
output "${_ERROR_}: $(get_text 'errorNothingToDo')!\\n"
|
||||||
else
|
else
|
||||||
output 0 "Starting $serviceName... "
|
if [ -s "$outputFile" ] || cache 'test' || cache 'test_gzip'; then
|
||||||
output 3 "Starting $serviceName...\\n"
|
output 0 "Force-reloading $serviceName... "
|
||||||
json set status "statusStarting"
|
output 3 "Force-reloading $serviceName...\\n"
|
||||||
|
json set status "statusForceReloading"
|
||||||
|
else
|
||||||
|
output 0 "Starting $serviceName... "
|
||||||
|
output 3 "Starting $serviceName...\\n"
|
||||||
|
json set status "statusStarting"
|
||||||
|
fi
|
||||||
|
if [ "$dns" = 'dnsmasq.conf' ] && [ -n "$dnsmasq_config_file_url" ]; then
|
||||||
|
download_dnsmasq_file
|
||||||
|
else
|
||||||
|
download_lists
|
||||||
|
fi
|
||||||
|
dns 'on_start'
|
||||||
fi
|
fi
|
||||||
if [ "$dns" = 'dnsmasq.conf' ] && [ -n "$dnsmasq_config_file_url" ]; then
|
|
||||||
download_dnsmasq_file
|
|
||||||
else
|
|
||||||
download_lists
|
|
||||||
fi
|
|
||||||
dns 'on_start'
|
|
||||||
fi
|
fi
|
||||||
if [ "$action" = 'restart' ]; then
|
if [ "$action" = 'restart' ]; then
|
||||||
output 0 "Restarting $serviceName... "
|
output 0 "Restarting $serviceName... "
|
||||||
|
|
Loading…
Reference in a new issue