mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-12-23 21:30:17 +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
|
||||
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
|
||||
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"
|
||||
|
@ -196,20 +210,6 @@ elif [[ -z "${all}" ]] && [[ "${#results[*]}" -ge 100 ]]; then
|
|||
exit 0
|
||||
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
|
||||
if [[ -n "${adlist}" ]] || [[ -n "${blockpage}" ]]; then
|
||||
# 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"
|
||||
# 03 -> wildcards
|
||||
readonly dhcpstaticconfig="/etc/dnsmasq.d/04-pihole-static-dhcp.conf"
|
||||
readonly PI_HOLE_BIN_DIR="/usr/local/bin"
|
||||
|
||||
readonly gravityDBfile="/etc/pihole/gravity.db"
|
||||
|
||||
|
@ -281,7 +282,7 @@ Reboot() {
|
|||
}
|
||||
|
||||
RestartDNS() {
|
||||
/usr/local/bin/pihole restartdns
|
||||
"${PI_HOLE_BIN_DIR}"/pihole restartdns
|
||||
}
|
||||
|
||||
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
|
||||
PI_HOLE_INSTALL_DIR="/opt/pihole"
|
||||
PI_HOLE_CONFIG_DIR="/etc/pihole"
|
||||
PI_HOLE_BIN_DIR="/usr/local/bin"
|
||||
PI_HOLE_BLOCKPAGE_DIR="${webroot}/pihole"
|
||||
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}" ./automated\ install/uninstall.sh
|
||||
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
|
||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
||||
|
||||
|
@ -1704,13 +1705,13 @@ installPiholeWeb() {
|
|||
# and copy in the pihole sudoers file
|
||||
install -m 0640 ${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole.sudo /etc/sudoers.d/pihole
|
||||
# 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 [[ "$LIGHTTPD_USER" == "lighttpd" ]]; then
|
||||
# Allow executing pihole via sudo with Fedora
|
||||
# Usually /usr/local/bin 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
|
||||
# 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:${PI_HOLE_BIN_DIR}" >> /etc/sudoers.d/pihole
|
||||
fi
|
||||
# Set the strict permissions on the file
|
||||
chmod 0440 /etc/sudoers.d/pihole
|
||||
|
@ -2413,7 +2414,7 @@ FTLcheckUpdate() {
|
|||
return 3
|
||||
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
|
||||
return 0
|
||||
|
@ -2699,7 +2700,7 @@ main() {
|
|||
|
||||
if [[ "${INSTALL_TYPE}" == "Update" ]]; then
|
||||
printf "\\n"
|
||||
/usr/local/bin/pihole version --current
|
||||
"${PI_HOLE_BIN_DIR}"/pihole version --current
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
43
gravity.sh
43
gravity.sh
|
@ -458,48 +458,7 @@ gravity_ParseFileIntoDomains() {
|
|||
# Determine how to parse individual source file formats
|
||||
if [[ "${firstLine,,}" =~ (adblock|ublock|^!) ]]; then
|
||||
# Compare $firstLine against lower case words found in Adblock lists
|
||||
echo -ne " ${INFO} Format: Adblock"
|
||||
|
||||
# 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"
|
||||
echo -e " ${CROSS} Format: Adblock (list type not supported)"
|
||||
elif grep -q "^address=/" "${source}" &> /dev/null; then
|
||||
# Parse Dnsmasq format lists
|
||||
echo -e " ${CROSS} Format: Dnsmasq (list type not supported)"
|
||||
|
|
27
pihole
27
pihole
|
@ -11,10 +11,11 @@
|
|||
|
||||
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
|
||||
# error due to modifying a readonly variable.
|
||||
setupVars="/etc/pihole/setupVars.conf"
|
||||
PI_HOLE_BIN_DIR="/usr/local/bin"
|
||||
|
||||
readonly colfile="${PI_HOLE_SCRIPT_DIR}/COL_TABLE"
|
||||
source "${colfile}"
|
||||
|
@ -101,20 +102,16 @@ versionFunc() {
|
|||
|
||||
restartDNS() {
|
||||
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
|
||||
# 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}"
|
||||
else
|
||||
# Get PID of resolver to determine if it needs to start or restart
|
||||
if pidof pihole-FTL &> /dev/null; then
|
||||
svcOption="restart"
|
||||
else
|
||||
svcOption="start"
|
||||
fi
|
||||
svc="service ${resolver} ${svcOption}"
|
||||
# A full restart has been requested
|
||||
svc="service ${resolver} restart"
|
||||
fi
|
||||
|
||||
# Print output to Terminal, but not to Web Admin
|
||||
|
@ -159,7 +156,7 @@ Time:
|
|||
local str="Disabling blocking for ${tt} seconds"
|
||||
echo -e " ${INFO} ${str}..."
|
||||
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
|
||||
local error=true
|
||||
fi
|
||||
|
@ -170,7 +167,7 @@ Time:
|
|||
echo -e " ${INFO} ${str}..."
|
||||
local str="Blocking will be re-enabled in ${tt} minutes"
|
||||
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
|
||||
local error=true
|
||||
fi
|
||||
|
@ -226,7 +223,7 @@ Options:
|
|||
sed -i 's/^QUERY_LOGGING=true/QUERY_LOGGING=false/' /etc/pihole/setupVars.conf
|
||||
if [[ "${2}" != "noflush" ]]; then
|
||||
# Flush logs
|
||||
pihole -f
|
||||
"${PI_HOLE_BIN_DIR}"/pihole -f
|
||||
fi
|
||||
echo -e " ${INFO} Disabling logging..."
|
||||
local str="Logging has been disabled!"
|
||||
|
@ -279,7 +276,7 @@ statusFunc() {
|
|||
*) echo -e " ${INFO} Pi-hole blocking will be enabled";;
|
||||
esac
|
||||
# Enable blocking
|
||||
pihole enable
|
||||
"${PI_HOLE_BIN_DIR}"/pihole enable
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue