mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Merge pull request #2938 from pi-hole/release/v4.3.2
Release v4.3.2 merge to development for update.
This commit is contained in:
commit
ae3b8be4d4
5 changed files with 36 additions and 78 deletions
28
advanced/Scripts/query.sh
Executable file → Normal file
28
advanced/Scripts/query.sh
Executable file → Normal file
|
@ -183,6 +183,20 @@ lists=("$(cd "$piholeDir" || exit 0; printf "%s\\n" -- *.domains | sort -V)")
|
||||||
# Query blocklists for occurences of domain
|
# Query blocklists for occurences of domain
|
||||||
mapfile -t results <<< "$(scanList "${domainQuery}" "${lists[*]}" "${exact}")"
|
mapfile -t results <<< "$(scanList "${domainQuery}" "${lists[*]}" "${exact}")"
|
||||||
|
|
||||||
|
# Remove unwanted content from $results
|
||||||
|
# Each line in $results is formatted as such: [fileName]:[line]
|
||||||
|
# 1. Delete lines starting with #
|
||||||
|
# 2. Remove comments after domain
|
||||||
|
# 3. Remove hosts format IP address
|
||||||
|
# 4. Remove any lines that no longer contain the queried domain name (in case the matched domain name was in a comment)
|
||||||
|
esc_domain="${domainQuery//./\\.}"
|
||||||
|
mapfile -t results <<< "$(IFS=$'\n'; sed \
|
||||||
|
-e "/:#/d" \
|
||||||
|
-e "s/[ \\t]#.*//g" \
|
||||||
|
-e "s/:.*[ \\t]/:/g" \
|
||||||
|
-e "/${esc_domain}/!d" \
|
||||||
|
<<< "${results[*]}")"
|
||||||
|
|
||||||
# Handle notices
|
# Handle notices
|
||||||
if [[ -z "${wbMatch:-}" ]] && [[ -z "${wcMatch:-}" ]] && [[ -z "${results[*]}" ]]; then
|
if [[ -z "${wbMatch:-}" ]] && [[ -z "${wcMatch:-}" ]] && [[ -z "${results[*]}" ]]; then
|
||||||
echo -e " ${INFO} No ${exact/t/t }results found for ${COL_BOLD}${domainQuery}${COL_NC} within the block lists"
|
echo -e " ${INFO} No ${exact/t/t }results found for ${COL_BOLD}${domainQuery}${COL_NC} within the block lists"
|
||||||
|
@ -196,20 +210,6 @@ elif [[ -z "${all}" ]] && [[ "${#results[*]}" -ge 100 ]]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove unwanted content from non-exact $results
|
|
||||||
if [[ -z "${exact}" ]]; then
|
|
||||||
# Delete lines starting with #
|
|
||||||
# Remove comments after domain
|
|
||||||
# Remove hosts format IP address
|
|
||||||
mapfile -t results <<< "$(IFS=$'\n'; sed \
|
|
||||||
-e "/:#/d" \
|
|
||||||
-e "s/[ \\t]#.*//g" \
|
|
||||||
-e "s/:.*[ \\t]/:/g" \
|
|
||||||
<<< "${results[*]}")"
|
|
||||||
# Exit if result was in a comment
|
|
||||||
[[ -z "${results[*]}" ]] && exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get adlist file content as array
|
# Get adlist file content as array
|
||||||
if [[ -n "${adlist}" ]] || [[ -n "${blockpage}" ]]; then
|
if [[ -n "${adlist}" ]] || [[ -n "${blockpage}" ]]; then
|
||||||
# Retrieve source URLs from gravity database
|
# Retrieve source URLs from gravity database
|
||||||
|
|
|
@ -16,6 +16,7 @@ readonly dhcpconfig="/etc/dnsmasq.d/02-pihole-dhcp.conf"
|
||||||
readonly FTLconf="/etc/pihole/pihole-FTL.conf"
|
readonly FTLconf="/etc/pihole/pihole-FTL.conf"
|
||||||
# 03 -> wildcards
|
# 03 -> wildcards
|
||||||
readonly dhcpstaticconfig="/etc/dnsmasq.d/04-pihole-static-dhcp.conf"
|
readonly dhcpstaticconfig="/etc/dnsmasq.d/04-pihole-static-dhcp.conf"
|
||||||
|
readonly PI_HOLE_BIN_DIR="/usr/local/bin"
|
||||||
|
|
||||||
readonly gravityDBfile="/etc/pihole/gravity.db"
|
readonly gravityDBfile="/etc/pihole/gravity.db"
|
||||||
|
|
||||||
|
@ -281,7 +282,7 @@ Reboot() {
|
||||||
}
|
}
|
||||||
|
|
||||||
RestartDNS() {
|
RestartDNS() {
|
||||||
/usr/local/bin/pihole restartdns
|
"${PI_HOLE_BIN_DIR}"/pihole restartdns
|
||||||
}
|
}
|
||||||
|
|
||||||
SetQueryLogOptions() {
|
SetQueryLogOptions() {
|
||||||
|
|
|
@ -65,6 +65,7 @@ PI_HOLE_FILES=(chronometer list piholeDebug piholeLogFlush setupLCD update versi
|
||||||
# This directory is where the Pi-hole scripts will be installed
|
# This directory is where the Pi-hole scripts will be installed
|
||||||
PI_HOLE_INSTALL_DIR="/opt/pihole"
|
PI_HOLE_INSTALL_DIR="/opt/pihole"
|
||||||
PI_HOLE_CONFIG_DIR="/etc/pihole"
|
PI_HOLE_CONFIG_DIR="/etc/pihole"
|
||||||
|
PI_HOLE_BIN_DIR="/usr/local/bin"
|
||||||
PI_HOLE_BLOCKPAGE_DIR="${webroot}/pihole"
|
PI_HOLE_BLOCKPAGE_DIR="${webroot}/pihole"
|
||||||
useUpdateVars=false
|
useUpdateVars=false
|
||||||
|
|
||||||
|
@ -1351,7 +1352,7 @@ installScripts() {
|
||||||
install -o "${USER}" -Dm755 -t "${PI_HOLE_INSTALL_DIR}" ./advanced/Scripts/*.sh
|
install -o "${USER}" -Dm755 -t "${PI_HOLE_INSTALL_DIR}" ./advanced/Scripts/*.sh
|
||||||
install -o "${USER}" -Dm755 -t "${PI_HOLE_INSTALL_DIR}" ./automated\ install/uninstall.sh
|
install -o "${USER}" -Dm755 -t "${PI_HOLE_INSTALL_DIR}" ./automated\ install/uninstall.sh
|
||||||
install -o "${USER}" -Dm755 -t "${PI_HOLE_INSTALL_DIR}" ./advanced/Scripts/COL_TABLE
|
install -o "${USER}" -Dm755 -t "${PI_HOLE_INSTALL_DIR}" ./advanced/Scripts/COL_TABLE
|
||||||
install -o "${USER}" -Dm755 -t /usr/local/bin/ pihole
|
install -o "${USER}" -Dm755 -t "${PI_HOLE_BIN_DIR}" pihole
|
||||||
install -Dm644 ./advanced/bash-completion/pihole /etc/bash_completion.d/pihole
|
install -Dm644 ./advanced/bash-completion/pihole /etc/bash_completion.d/pihole
|
||||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
||||||
|
|
||||||
|
@ -1704,13 +1705,13 @@ installPiholeWeb() {
|
||||||
# and copy in the pihole sudoers file
|
# and copy in the pihole sudoers file
|
||||||
install -m 0640 ${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole.sudo /etc/sudoers.d/pihole
|
install -m 0640 ${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole.sudo /etc/sudoers.d/pihole
|
||||||
# Add lighttpd user (OS dependent) to sudoers file
|
# Add lighttpd user (OS dependent) to sudoers file
|
||||||
echo "${LIGHTTPD_USER} ALL=NOPASSWD: /usr/local/bin/pihole" >> /etc/sudoers.d/pihole
|
echo "${LIGHTTPD_USER} ALL=NOPASSWD: ${PI_HOLE_BIN_DIR}/pihole" >> /etc/sudoers.d/pihole
|
||||||
|
|
||||||
# If the Web server user is lighttpd,
|
# If the Web server user is lighttpd,
|
||||||
if [[ "$LIGHTTPD_USER" == "lighttpd" ]]; then
|
if [[ "$LIGHTTPD_USER" == "lighttpd" ]]; then
|
||||||
# Allow executing pihole via sudo with Fedora
|
# Allow executing pihole via sudo with Fedora
|
||||||
# Usually /usr/local/bin is not permitted as directory for sudoable programs
|
# Usually /usr/local/bin ${PI_HOLE_BIN_DIR} is not permitted as directory for sudoable programs
|
||||||
echo "Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin" >> /etc/sudoers.d/pihole
|
echo "Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:${PI_HOLE_BIN_DIR}" >> /etc/sudoers.d/pihole
|
||||||
fi
|
fi
|
||||||
# Set the strict permissions on the file
|
# Set the strict permissions on the file
|
||||||
chmod 0440 /etc/sudoers.d/pihole
|
chmod 0440 /etc/sudoers.d/pihole
|
||||||
|
@ -2413,7 +2414,7 @@ FTLcheckUpdate() {
|
||||||
return 3
|
return 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FTLlatesttag=$(grep 'Location' < "${FTLreleaseData}" | awk -F '/' '{print $NF}' | tr -d '\r\n')
|
FTLlatesttag=$(grep 'Location' <<< "${FTLreleaseData}" | awk -F '/' '{print $NF}' | tr -d '\r\n')
|
||||||
|
|
||||||
if [[ "${FTLversion}" != "${FTLlatesttag}" ]]; then
|
if [[ "${FTLversion}" != "${FTLlatesttag}" ]]; then
|
||||||
return 0
|
return 0
|
||||||
|
@ -2699,7 +2700,7 @@ main() {
|
||||||
|
|
||||||
if [[ "${INSTALL_TYPE}" == "Update" ]]; then
|
if [[ "${INSTALL_TYPE}" == "Update" ]]; then
|
||||||
printf "\\n"
|
printf "\\n"
|
||||||
/usr/local/bin/pihole version --current
|
"${PI_HOLE_BIN_DIR}"/pihole version --current
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
43
gravity.sh
43
gravity.sh
|
@ -458,48 +458,7 @@ gravity_ParseFileIntoDomains() {
|
||||||
# Determine how to parse individual source file formats
|
# Determine how to parse individual source file formats
|
||||||
if [[ "${firstLine,,}" =~ (adblock|ublock|^!) ]]; then
|
if [[ "${firstLine,,}" =~ (adblock|ublock|^!) ]]; then
|
||||||
# Compare $firstLine against lower case words found in Adblock lists
|
# Compare $firstLine against lower case words found in Adblock lists
|
||||||
echo -ne " ${INFO} Format: Adblock"
|
echo -e " ${CROSS} Format: Adblock (list type not supported)"
|
||||||
|
|
||||||
# Define symbols used as comments: [!
|
|
||||||
# "||.*^" includes the "Example 2" domains we can extract
|
|
||||||
# https://adblockplus.org/filter-cheatsheet
|
|
||||||
abpFilter="/^(\\[|!)|^(\\|\\|.*\\^)/"
|
|
||||||
|
|
||||||
# Parse Adblock lists by extracting "Example 2" domains
|
|
||||||
# Logic: Ignore lines which do not include comments or domain name anchor
|
|
||||||
awk ''"${abpFilter}"' {
|
|
||||||
# Remove valid adblock type options
|
|
||||||
gsub(/\$?~?(important|third-party|popup|subdocument|websocket),?/, "", $0)
|
|
||||||
# Remove starting domain name anchor "||" and ending seperator "^"
|
|
||||||
gsub(/^(\|\|)|(\^)/, "", $0)
|
|
||||||
# Remove invalid characters (*/,=$)
|
|
||||||
if($0 ~ /[*\/,=\$]/) { $0="" }
|
|
||||||
# Remove lines which are only IPv4 addresses
|
|
||||||
if($0 ~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) { $0="" }
|
|
||||||
if($0) { print $0 }
|
|
||||||
}' "${source}" > "${destination}"
|
|
||||||
chmod 644 "${destination}"
|
|
||||||
|
|
||||||
# Determine if there are Adblock exception rules
|
|
||||||
# https://adblockplus.org/filters
|
|
||||||
if grep -q "^@@||" "${source}" &> /dev/null; then
|
|
||||||
# Parse Adblock lists by extracting exception rules
|
|
||||||
# Logic: Ignore lines which do not include exception format "@@||example.com^"
|
|
||||||
awk -F "[|^]" '/^@@\|\|.*\^/ {
|
|
||||||
# Remove valid adblock type options
|
|
||||||
gsub(/\$?~?(third-party)/, "", $0)
|
|
||||||
# Remove invalid characters (*/,=$)
|
|
||||||
if($0 ~ /[*\/,=\$]/) { $0="" }
|
|
||||||
if($3) { print $3 }
|
|
||||||
}' "${source}" > "${destination}.exceptionsFile.tmp"
|
|
||||||
|
|
||||||
# Remove exceptions
|
|
||||||
comm -23 "${destination}" <(sort "${destination}.exceptionsFile.tmp") > "${source}"
|
|
||||||
mv "${source}" "${destination}"
|
|
||||||
chmod 644 "${destination}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "${OVER} ${TICK} Format: Adblock"
|
|
||||||
elif grep -q "^address=/" "${source}" &> /dev/null; then
|
elif grep -q "^address=/" "${source}" &> /dev/null; then
|
||||||
# Parse Dnsmasq format lists
|
# Parse Dnsmasq format lists
|
||||||
echo -e " ${CROSS} Format: Dnsmasq (list type not supported)"
|
echo -e " ${CROSS} Format: Dnsmasq (list type not supported)"
|
||||||
|
|
27
pihole
27
pihole
|
@ -11,10 +11,11 @@
|
||||||
|
|
||||||
readonly PI_HOLE_SCRIPT_DIR="/opt/pihole"
|
readonly PI_HOLE_SCRIPT_DIR="/opt/pihole"
|
||||||
|
|
||||||
# setupVars is not readonly here because in some functions (checkout),
|
# setupVars and PI_HOLE_BIN_DIR are not readonly here because in some funcitons (checkout),
|
||||||
# it might get set again when the installer is sourced. This causes an
|
# it might get set again when the installer is sourced. This causes an
|
||||||
# error due to modifying a readonly variable.
|
# error due to modifying a readonly variable.
|
||||||
setupVars="/etc/pihole/setupVars.conf"
|
setupVars="/etc/pihole/setupVars.conf"
|
||||||
|
PI_HOLE_BIN_DIR="/usr/local/bin"
|
||||||
|
|
||||||
readonly colfile="${PI_HOLE_SCRIPT_DIR}/COL_TABLE"
|
readonly colfile="${PI_HOLE_SCRIPT_DIR}/COL_TABLE"
|
||||||
source "${colfile}"
|
source "${colfile}"
|
||||||
|
@ -101,20 +102,16 @@ versionFunc() {
|
||||||
|
|
||||||
restartDNS() {
|
restartDNS() {
|
||||||
local svcOption svc str output status
|
local svcOption svc str output status
|
||||||
svcOption="${1:-}"
|
svcOption="${1:-restart}"
|
||||||
|
|
||||||
# Determine if we should reload or restart restart
|
# Determine if we should reload or restart
|
||||||
if [[ "${svcOption}" =~ "reload" ]]; then
|
if [[ "${svcOption}" =~ "reload" ]]; then
|
||||||
# Using SIGHUP will NOT re-read any *.conf files
|
# Reload has been requested
|
||||||
|
# Note: This will NOT re-read any *.conf files
|
||||||
svc="killall -s SIGHUP ${resolver}"
|
svc="killall -s SIGHUP ${resolver}"
|
||||||
else
|
else
|
||||||
# Get PID of resolver to determine if it needs to start or restart
|
# A full restart has been requested
|
||||||
if pidof pihole-FTL &> /dev/null; then
|
svc="service ${resolver} restart"
|
||||||
svcOption="restart"
|
|
||||||
else
|
|
||||||
svcOption="start"
|
|
||||||
fi
|
|
||||||
svc="service ${resolver} ${svcOption}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Print output to Terminal, but not to Web Admin
|
# Print output to Terminal, but not to Web Admin
|
||||||
|
@ -159,7 +156,7 @@ Time:
|
||||||
local str="Disabling blocking for ${tt} seconds"
|
local str="Disabling blocking for ${tt} seconds"
|
||||||
echo -e " ${INFO} ${str}..."
|
echo -e " ${INFO} ${str}..."
|
||||||
local str="Blocking will be re-enabled in ${tt} seconds"
|
local str="Blocking will be re-enabled in ${tt} seconds"
|
||||||
nohup bash -c "sleep ${tt}; pihole enable" </dev/null &>/dev/null &
|
nohup bash -c "sleep ${tt}; ${PI_HOLE_BIN_DIR}/pihole enable" </dev/null &>/dev/null &
|
||||||
else
|
else
|
||||||
local error=true
|
local error=true
|
||||||
fi
|
fi
|
||||||
|
@ -170,7 +167,7 @@ Time:
|
||||||
echo -e " ${INFO} ${str}..."
|
echo -e " ${INFO} ${str}..."
|
||||||
local str="Blocking will be re-enabled in ${tt} minutes"
|
local str="Blocking will be re-enabled in ${tt} minutes"
|
||||||
tt=$((${tt}*60))
|
tt=$((${tt}*60))
|
||||||
nohup bash -c "sleep ${tt}; pihole enable" </dev/null &>/dev/null &
|
nohup bash -c "sleep ${tt}; ${PI_HOLE_BIN_DIR}/pihole enable" </dev/null &>/dev/null &
|
||||||
else
|
else
|
||||||
local error=true
|
local error=true
|
||||||
fi
|
fi
|
||||||
|
@ -226,7 +223,7 @@ Options:
|
||||||
sed -i 's/^QUERY_LOGGING=true/QUERY_LOGGING=false/' /etc/pihole/setupVars.conf
|
sed -i 's/^QUERY_LOGGING=true/QUERY_LOGGING=false/' /etc/pihole/setupVars.conf
|
||||||
if [[ "${2}" != "noflush" ]]; then
|
if [[ "${2}" != "noflush" ]]; then
|
||||||
# Flush logs
|
# Flush logs
|
||||||
pihole -f
|
"${PI_HOLE_BIN_DIR}"/pihole -f
|
||||||
fi
|
fi
|
||||||
echo -e " ${INFO} Disabling logging..."
|
echo -e " ${INFO} Disabling logging..."
|
||||||
local str="Logging has been disabled!"
|
local str="Logging has been disabled!"
|
||||||
|
@ -279,7 +276,7 @@ statusFunc() {
|
||||||
*) echo -e " ${INFO} Pi-hole blocking will be enabled";;
|
*) echo -e " ${INFO} Pi-hole blocking will be enabled";;
|
||||||
esac
|
esac
|
||||||
# Enable blocking
|
# Enable blocking
|
||||||
pihole enable
|
"${PI_HOLE_BIN_DIR}"/pihole enable
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue