mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-22 14:58:08 +00:00
Add flag abp_domains into info table to signal if abp domains have been found
Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
parent
821c7dc190
commit
6cb0be82ca
22
gravity.sh
22
gravity.sh
@ -137,6 +137,18 @@ update_gravity_timestamp() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Update timestamp when the gravity table was last updated successfully
|
||||||
|
set_abp_info() {
|
||||||
|
pihole-FTL sqlite3 "${gravityDBfile}" "INSERT OR REPLACE INTO info (property,value) VALUES ('abp_domains',${abp_domains});"
|
||||||
|
status="$?"
|
||||||
|
|
||||||
|
if [[ "${status}" -ne 0 ]]; then
|
||||||
|
echo -e "\\n ${CROSS} Unable to update ABP domain status in database ${gravityDBfile}\\n ${output}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
# Import domains from file and store them in the specified database table
|
# Import domains from file and store them in the specified database table
|
||||||
database_table_from_file() {
|
database_table_from_file() {
|
||||||
# Define locals
|
# Define locals
|
||||||
@ -519,6 +531,10 @@ gravity_DownloadBlocklists() {
|
|||||||
gravity_Blackbody=true
|
gravity_Blackbody=true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# global variable to indicate if we found ABP style domains during the gravity run
|
||||||
|
# is saved in gravtiy's info table to signal FTL if such domains are available
|
||||||
|
abp_domains=0
|
||||||
parseList() {
|
parseList() {
|
||||||
local adlistID="${1}" src="${2}" target="${3}" temp_file temp_file_base non_domains sample_non_domains
|
local adlistID="${1}" src="${2}" target="${3}" temp_file temp_file_base non_domains sample_non_domains
|
||||||
|
|
||||||
@ -536,9 +552,10 @@ parseList() {
|
|||||||
# no need to include uppercase letters, as we convert to lowercase in gravity_ParseFileIntoDomains() already
|
# no need to include uppercase letters, as we convert to lowercase in gravity_ParseFileIntoDomains() already
|
||||||
sed -r "/^([a-z0-9]([a-z0-9_-]{0,61}[a-z0-9]){0,1}\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$/!d" "${src}" > "${temp_file}"
|
sed -r "/^([a-z0-9]([a-z0-9_-]{0,61}[a-z0-9]){0,1}\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$/!d" "${src}" > "${temp_file}"
|
||||||
|
|
||||||
# if there is at least one ABP style domains
|
# if there is at least one ABP style domain
|
||||||
if grep -E "^\|\|([a-z0-9]([a-z0-9_-]{0,61}[a-z0-9]){0,1}\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]" -m 1 -q "${src}"; then
|
if grep -E "^\|\|([a-z0-9]([a-z0-9_-]{0,61}[a-z0-9]){0,1}\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]" -m 1 -q "${src}"; then
|
||||||
echo " ${INFO} List contained AdBlock Plus style domains"
|
echo " ${INFO} List contained AdBlock Plus style domains"
|
||||||
|
abp_domains=1
|
||||||
# 2. Add all supported ABP style lines (||subdomain.domain.tlp^)
|
# 2. Add all supported ABP style lines (||subdomain.domain.tlp^)
|
||||||
sed -r "/^\|\|([a-z0-9]([a-z0-9_-]{0,61}[a-z0-9]){0,1}\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]\^$/!d" "${src}" >> "${temp_file}"
|
sed -r "/^\|\|([a-z0-9]([a-z0-9_-]{0,61}[a-z0-9]){0,1}\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]\^$/!d" "${src}" >> "${temp_file}"
|
||||||
fi
|
fi
|
||||||
@ -1014,6 +1031,9 @@ fi
|
|||||||
# Update gravity timestamp
|
# Update gravity timestamp
|
||||||
update_gravity_timestamp
|
update_gravity_timestamp
|
||||||
|
|
||||||
|
# Set abp_domain info field
|
||||||
|
set_abp_info
|
||||||
|
|
||||||
# Ensure proper permissions are set for the database
|
# Ensure proper permissions are set for the database
|
||||||
chown pihole:pihole "${gravityDBfile}"
|
chown pihole:pihole "${gravityDBfile}"
|
||||||
chmod g+w "${piholeDir}" "${gravityDBfile}"
|
chmod g+w "${piholeDir}" "${gravityDBfile}"
|
||||||
|
Loading…
Reference in New Issue
Block a user