mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Rename adlists -> adlist table.
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
parent
3a14e8b013
commit
f91421418a
2 changed files with 17 additions and 17 deletions
|
@ -59,7 +59,7 @@ CREATE TABLE regex_by_group
|
|||
PRIMARY KEY (regex_id, group_id)
|
||||
);
|
||||
|
||||
CREATE TABLE adlists
|
||||
CREATE TABLE adlist
|
||||
(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
address TEXT UNIQUE NOT NULL,
|
||||
|
@ -69,11 +69,11 @@ CREATE TABLE adlists
|
|||
comment TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE adlists_by_group
|
||||
CREATE TABLE adlist_by_group
|
||||
(
|
||||
adlists_id INTEGER NOT NULL REFERENCES adlists (id),
|
||||
adlist_id INTEGER NOT NULL REFERENCES adlist (id),
|
||||
group_id INTEGER NOT NULL REFERENCES "group" (id),
|
||||
PRIMARY KEY (adlists_id, group_id)
|
||||
PRIMARY KEY (adlist_id, group_id)
|
||||
);
|
||||
|
||||
CREATE TABLE gravity
|
||||
|
@ -128,15 +128,15 @@ CREATE TRIGGER tr_regex_update AFTER UPDATE ON regex
|
|||
UPDATE regex SET date_modified = (cast(strftime('%s', 'now') as int)) WHERE domain = NEW.domain;
|
||||
END;
|
||||
|
||||
CREATE VIEW vw_adlists AS SELECT address
|
||||
FROM adlists
|
||||
LEFT JOIN adlists_by_group ON adlists_by_group.adlists_id = adlists.id
|
||||
LEFT JOIN "group" ON "group".id = adlists_by_group.group_id
|
||||
WHERE adlists.enabled = 1 AND (adlists_by_group.group_id IS NULL OR "group".enabled = 1)
|
||||
ORDER BY adlists.id;
|
||||
CREATE VIEW vw_adlist AS SELECT address
|
||||
FROM adlist
|
||||
LEFT JOIN adlist_by_group ON adlist_by_group.adlist_id = adlist.id
|
||||
LEFT JOIN "group" ON "group".id = adlist_by_group.group_id
|
||||
WHERE adlist.enabled = 1 AND (adlist_by_group.group_id IS NULL OR "group".enabled = 1)
|
||||
ORDER BY adlist.id;
|
||||
|
||||
CREATE TRIGGER tr_adlists_update AFTER UPDATE ON adlists
|
||||
CREATE TRIGGER tr_adlist_update AFTER UPDATE ON adlist
|
||||
BEGIN
|
||||
UPDATE adlists SET date_modified = (cast(strftime('%s', 'now') as int)) WHERE address = NEW.address;
|
||||
UPDATE adlist SET date_modified = (cast(strftime('%s', 'now') as int)) WHERE address = NEW.address;
|
||||
END;
|
||||
|
||||
|
|
10
gravity.sh
10
gravity.sh
|
@ -111,7 +111,7 @@ database_table_from_file() {
|
|||
# No need to modify the input data for the gravity table
|
||||
inputfile="${source}"
|
||||
else
|
||||
# Apply format for white-, blacklist, regex, and adlists tables
|
||||
# Apply format for white-, blacklist, regex, and adlist tables
|
||||
local rowid
|
||||
declare -i rowid
|
||||
rowid=1
|
||||
|
@ -159,9 +159,9 @@ migrate_to_database() {
|
|||
|
||||
# Migrate list files to new database
|
||||
if [[ -e "${adListFile}" ]]; then
|
||||
# Store adlists domains in database
|
||||
# Store adlist domains in database
|
||||
echo -e " ${INFO} Migrating content of ${adListFile} into new database"
|
||||
database_table_from_file "adlists" "${adListFile}"
|
||||
database_table_from_file "adlist" "${adListFile}"
|
||||
fi
|
||||
if [[ -e "${blacklistFile}" ]]; then
|
||||
# Store blacklisted domains in database
|
||||
|
@ -236,13 +236,13 @@ gravity_CheckDNSResolutionAvailable() {
|
|||
gravity_CheckDNSResolutionAvailable
|
||||
}
|
||||
|
||||
# Retrieve blocklist URLs and parse domains from adlists.list
|
||||
# Retrieve blocklist URLs and parse domains from adlist.list
|
||||
gravity_GetBlocklistUrls() {
|
||||
echo -e " ${INFO} ${COL_BOLD}Neutrino emissions detected${COL_NC}..."
|
||||
|
||||
# Retrieve source URLs from gravity database
|
||||
# We source only enabled adlists, sqlite3 stores boolean values as 0 (false) or 1 (true)
|
||||
mapfile -t sources <<< "$(sqlite3 "${gravityDBfile}" "SELECT address FROM vw_adlists;" 2> /dev/null)"
|
||||
mapfile -t sources <<< "$(sqlite3 "${gravityDBfile}" "SELECT address FROM vw_adlist;" 2> /dev/null)"
|
||||
|
||||
# Parse source domains from $sources
|
||||
mapfile -t sourceDomains <<< "$(
|
||||
|
|
Loading…
Reference in a new issue