Source adlists from gravity database

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2019-04-25 10:46:18 +02:00
parent 2664ac0efc
commit 465a39427b
No known key found for this signature in database
GPG key ID: 00135ACBD90B28DD

View file

@ -151,9 +151,8 @@ database_table_from_file() {
echo -e " ${CROSS} Unable to remove ${source}" echo -e " ${CROSS} Unable to remove ${source}"
} }
# Migrate pre-v5.0 list files to database-based Pi-hole versions
migrate_to_database() { migrate_to_database() {
ls -lh
# Migrate pre-v5.0 list files to database-based Pi-hole versions
if [[ -e "${whitelistFile}" ]]; then if [[ -e "${whitelistFile}" ]]; then
# Store whitelisted domains in database # Store whitelisted domains in database
database_table_from_file "whitelist" "${whitelistFile}" database_table_from_file "whitelist" "${whitelistFile}"
@ -232,15 +231,9 @@ gravity_CheckDNSResolutionAvailable() {
gravity_GetBlocklistUrls() { gravity_GetBlocklistUrls() {
echo -e " ${INFO} ${COL_BOLD}Neutrino emissions detected${COL_NC}..." echo -e " ${INFO} ${COL_BOLD}Neutrino emissions detected${COL_NC}..."
if [[ -f "${adListDefault}" ]] && [[ -f "${adListFile}" ]]; then # Retrieve source URLs from gravity database
# Remove superseded $adListDefault file # We source only enabled adlists, sqlite3 stores boolean values as 0 (false) or 1 (true)
rm "${adListDefault}" 2> /dev/null || \ mapfile -t sources <<< "$(sqlite3 "${gravityDBfile}" "SELECT address FROM adlists WHERE enabled = 1;" 2> /dev/null)"
echo -e " ${CROSS} Unable to remove ${adListDefault}"
fi
# Retrieve source URLs from $adListFile
# Logic: Remove comments and empty lines
mapfile -t sources <<< "$(grep -v -E "^(#|$)" "${adListFile}" 2> /dev/null)"
# Parse source domains from $sources # Parse source domains from $sources
mapfile -t sourceDomains <<< "$( mapfile -t sourceDomains <<< "$(