From e0eb5eb2b1bb5fc5772aac479f71d4dfb77237ac Mon Sep 17 00:00:00 2001 From: WaLLy3K Date: Wed, 26 Jul 2017 08:07:06 +1000 Subject: [PATCH] Fix queryFunc if adlists URLs have been removed (#1618) * Fix queryFunc if adlists URLs have been removed * Allow for -adlists command line switch (where the "s" is a typo) * Add error message when unable to find associated adlists URL * Provide PR fix on current dev version * Add blResult variable for white/black match * Supporting Block Page queryFunc fixes * Re-add unmerged lines --- pihole | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pihole b/pihole index 8da911d8..61ed6cd6 100755 --- a/pihole +++ b/pihole @@ -149,7 +149,7 @@ Options: fi # Strip valid options, leaving only the domain and invalid options - options=$(sed 's/ \?-\(exact\|adlist\|bp\|all\) \?//g' <<< "$options") + options=$(sed 's/ \?-\(exact\|adlist\(s\)\?\|bp\|all\) \?//g' <<< "$options") # Handle errors if [[ "${options}" == *" "* ]]; then @@ -181,13 +181,14 @@ Options: results=($(scanList "${query}" "${lists}" "${method}")) if [[ -n "${results[*]}" ]]; then + blResult=true # Loop through each scanList line to print appropriate title for result in "${results[@]}"; do filename="${result/:*/}" if [[ -n "$exact" ]]; then printf " Exact result in %s\n" "${filename}" elif [[ -n "$blockpage" ]]; then - printf " [i] %s\n" "${filename}" + printf "π %s\n" "${filename}" else domain="${result/*:/}" if [[ ! "${filename}" == "${filename_prev:-}" ]]; then @@ -216,7 +217,7 @@ Options: fi if [[ -n "${blockpage}" ]]; then - echo " ${INFO} ${match}" + echo "π ${wildcardlist/*\/}" else echo " *.${match}" fi @@ -287,12 +288,18 @@ Options: filenum=("${filename/list./}") filenum=("${filenum/.*/}") filename="${adlists[$filenum]}" + + # If gravity has generated associated .domains files + # but adlists.list has been modified since + if [[ -z "${filename}" ]]; then + filename="${COL_LIGHT_RED}Error: no associated adlists URL found${COL_NC}" + fi fi if [[ -n "${exact}" ]]; then printf " %s\n" "${filename}" elif [[ -n "${blockpage}" ]]; then - printf " [%s] %s\n" "${filenum}" "${filename}" + printf "%s %s\n" "${filenum}" "${filename}" else # Standard query output # Print filename heading once per file, not for every match