Remove the blockpage-focussed customisations to query.sh

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
Adam Warner 2022-08-08 18:57:17 +01:00
parent 97447b2f3b
commit e35a9da921
No known key found for this signature in database
GPG key ID: 872950F3ECF2B173

View file

@ -16,7 +16,6 @@ GRAVITYDB="${piholeDir}/gravity.db"
options="$*" options="$*"
all="" all=""
exact="" exact=""
blockpage=""
matchType="match" matchType="match"
# Source pihole-FTL from install script # Source pihole-FTL from install script
pihole_FTL="${piholeDir}/pihole-FTL.conf" pihole_FTL="${piholeDir}/pihole-FTL.conf"
@ -71,18 +70,14 @@ Options:
fi fi
# Handle valid options # Handle valid options
if [[ "${options}" == *"-bp"* ]]; then [[ "${options}" == *"-all"* ]] && all=true
exact="exact"; blockpage=true if [[ "${options}" == *"-exact"* ]]; then
else exact="exact"; matchType="exact ${matchType}"
[[ "${options}" == *"-all"* ]] && all=true
if [[ "${options}" == *"-exact"* ]]; then
exact="exact"; matchType="exact ${matchType}"
fi
fi fi
# Strip valid options, leaving only the domain and invalid options # Strip valid options, leaving only the domain and invalid options
# This allows users to place the options before or after the domain # This allows users to place the options before or after the domain
options=$(sed -E 's/ ?-(bp|adlists?|all|exact) ?//g' <<< "${options}") options=$(sed -E 's/ ?-(adlists?|all|exact) ?//g' <<< "${options}")
# Handle remaining options # Handle remaining options
# If $options contain non ASCII characters, convert to punycode # If $options contain non ASCII characters, convert to punycode
@ -136,17 +131,11 @@ scanDatabaseTable() {
wbMatch=true wbMatch=true
# Print table name # Print table name
if [[ -z "${blockpage}" ]]; then echo " ${matchType^} found in ${COL_BOLD}exact ${table}${COL_NC}"
echo " ${matchType^} found in ${COL_BOLD}exact ${table}${COL_NC}"
fi
# Loop over results and print them # Loop over results and print them
mapfile -t results <<< "${result}" mapfile -t results <<< "${result}"
for result in "${results[@]}"; do for result in "${results[@]}"; do
if [[ -n "${blockpage}" ]]; then
echo "π ${result}"
exit 0
fi
domain="${result/|*}" domain="${result/|*}"
if [[ "${result#*|}" == "0" ]]; then if [[ "${result#*|}" == "0" ]]; then
extra=" (disabled)" extra=" (disabled)"
@ -181,18 +170,13 @@ scanRegexDatabaseTable() {
# Form a "results" message # Form a "results" message
str_result="${COL_BOLD}${str_regexMatches}${COL_NC}" str_result="${COL_BOLD}${str_regexMatches}${COL_NC}"
# If we are displaying more than just the source of the block # If we are displaying more than just the source of the block
if [[ -z "${blockpage}" ]]; then # Set the wildcard match flag
# Set the wildcard match flag wcMatch=true
wcMatch=true # Echo the "matched" message, indented by one space
# Echo the "matched" message, indented by one space echo " ${str_message}"
echo " ${str_message}" # Echo the "results" message, each line indented by three spaces
# Echo the "results" message, each line indented by three spaces # shellcheck disable=SC2001
# shellcheck disable=SC2001 echo "${str_result}" | sed 's/^/ /'
echo "${str_result}" | sed 's/^/ /'
else
echo "π .wildcard"
exit 0
fi
fi fi
fi fi
} }
@ -222,7 +206,7 @@ elif [[ -z "${all}" ]] && [[ "${#results[*]}" -ge 100 ]]; then
fi fi
# Print "Exact matches for" title # Print "Exact matches for" title
if [[ -n "${exact}" ]] && [[ -z "${blockpage}" ]]; then if [[ -n "${exact}" ]]; then
plural=""; [[ "${#results[*]}" -gt 1 ]] && plural="es" plural=""; [[ "${#results[*]}" -gt 1 ]] && plural="es"
echo " ${matchType^}${plural} for ${COL_BOLD}${domainQuery}${COL_NC} found in:" echo " ${matchType^}${plural} for ${COL_BOLD}${domainQuery}${COL_NC} found in:"
fi fi
@ -238,9 +222,7 @@ for result in "${results[@]}"; do
extra="" extra=""
fi fi
if [[ -n "${blockpage}" ]]; then if [[ -n "${exact}" ]]; then
echo "0 ${adlistAddress}"
elif [[ -n "${exact}" ]]; then
echo " - ${adlistAddress}${extra}" echo " - ${adlistAddress}${extra}"
else else
if [[ ! "${adlistAddress}" == "${adlistAddress_prev:-}" ]]; then if [[ ! "${adlistAddress}" == "${adlistAddress_prev:-}" ]]; then