mirror of
https://github.com/pi-hole/pi-hole
synced 2025-01-03 12:40:56 +00:00
Store regex in gravity.db as well
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
parent
dcf0a605cf
commit
93f1859bab
@ -1,5 +1,6 @@
|
|||||||
CREATE TABLE whitelist (domain TEXT UNIQUE NOT NULL, disabled BOOLEAN DEFAULT 0, comment TEXT, DateAdded DATETIME);
|
CREATE TABLE whitelist (domain TEXT UNIQUE NOT NULL, disabled BOOLEAN DEFAULT 0, comment TEXT, DateAdded DATETIME);
|
||||||
CREATE TABLE blacklist (domain TEXT UNIQUE NOT NULL, disabled BOOLEAN DEFAULT 0, comment TEXT, DateAdded DATETIME);
|
CREATE TABLE blacklist (domain TEXT UNIQUE NOT NULL, disabled BOOLEAN DEFAULT 0, comment TEXT, DateAdded DATETIME);
|
||||||
|
CREATE TABLE regex (domain TEXT UNIQUE NOT NULL, disabled BOOLEAN DEFAULT 0, comment TEXT, DateAdded DATETIME);
|
||||||
CREATE TABLE gravity (domain TEXT UNIQUE NOT NULL);
|
CREATE TABLE gravity (domain TEXT UNIQUE NOT NULL);
|
||||||
|
|
||||||
CREATE VIEW vw_gravity AS SELECT DISTINCT a.domain
|
CREATE VIEW vw_gravity AS SELECT DISTINCT a.domain
|
||||||
@ -14,3 +15,7 @@ WHERE a.disabled != 1 AND
|
|||||||
CREATE VIEW vw_whitelist AS SELECT DISTINCT a.domain
|
CREATE VIEW vw_whitelist AS SELECT DISTINCT a.domain
|
||||||
FROM whitelist a
|
FROM whitelist a
|
||||||
WHERE a.disabled != 1;
|
WHERE a.disabled != 1;
|
||||||
|
|
||||||
|
CREATE VIEW vw_regex AS SELECT DISTINCT a.domain
|
||||||
|
FROM regex a
|
||||||
|
WHERE a.disabled != 1;
|
||||||
|
@ -124,7 +124,7 @@ gravity_store_in_database() {
|
|||||||
gravity_Cleanup "error"
|
gravity_Cleanup "error"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$table" == "whitelist" ] || [ "$table" == "blacklist" ]; then
|
if [ "$table" == "whitelist" ] || [ "$table" == "blacklist" ] || [ "$table" == "regex" ]; then
|
||||||
# Set disabled to false
|
# Set disabled to false
|
||||||
output=$( { sqlite3 "${gravityDBfile}" <<< "UPDATE ${table} SET disabled = 0 WHERE disabled IS NULL;"; } 2>&1 )
|
output=$( { sqlite3 "${gravityDBfile}" <<< "UPDATE ${table} SET disabled = 0 WHERE disabled IS NULL;"; } 2>&1 )
|
||||||
status="$?"
|
status="$?"
|
||||||
@ -135,6 +135,8 @@ gravity_store_in_database() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Only create template file if asked to
|
||||||
|
if [ "${template}" != "-" ]; then
|
||||||
# Empty $template if it already exists, otherwise, create it
|
# Empty $template if it already exists, otherwise, create it
|
||||||
output=$( { : > "${template}"; } 2>&1 )
|
output=$( { : > "${template}"; } 2>&1 )
|
||||||
status="$?"
|
status="$?"
|
||||||
@ -143,6 +145,7 @@ gravity_store_in_database() {
|
|||||||
echo -e "\\n ${CROSS} Unable to create empty ${template}\\n ${output}"
|
echo -e "\\n ${CROSS} Unable to create empty ${template}\\n ${output}"
|
||||||
gravity_Cleanup "error"
|
gravity_Cleanup "error"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Determine if Pi-hole blocking is disabled
|
# Determine if Pi-hole blocking is disabled
|
||||||
@ -586,6 +589,9 @@ gravity_ShowBlockCount() {
|
|||||||
num=$(grep -cv "^#" "${regexFile}")
|
num=$(grep -cv "^#" "${regexFile}")
|
||||||
echo -e " ${INFO} Number of regex filters: ${num}"
|
echo -e " ${INFO} Number of regex filters: ${num}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Store regex files in gravity database
|
||||||
|
gravity_store_in_database "regex" "${regexFile}" "-"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Parse list of domains into hosts format
|
# Parse list of domains into hosts format
|
||||||
|
Loading…
Reference in New Issue
Block a user