mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-09-22 01:29:10 +02:00
Rename views, upgrade gravity database and bump gravity databae version
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
parent
75286a1626
commit
9e258e7005
@ -150,4 +150,10 @@ upgrade_gravityDB(){
|
|||||||
pihole-FTL sqlite3 -ni "${database}" < "${scriptPath}/18_to_19.sql"
|
pihole-FTL sqlite3 -ni "${database}" < "${scriptPath}/18_to_19.sql"
|
||||||
version=19
|
version=19
|
||||||
fi
|
fi
|
||||||
|
if [[ "$version" == "19" ]]; then
|
||||||
|
# Update views to use new allowlist/denylist names
|
||||||
|
echo -e " ${INFO} Upgrading gravity database from version 19 to 20"
|
||||||
|
pihole-FTL sqlite3 -ni "${database}" < "${scriptPath}/19_to_20.sql"
|
||||||
|
version=20
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
43
advanced/Scripts/database_migration/gravity/19_to_20.sql
Normal file
43
advanced/Scripts/database_migration/gravity/19_to_20.sql
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
.timeout 30000
|
||||||
|
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
DROP VIEW vw_whitelist;
|
||||||
|
CREATE VIEW vw_allowlist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
||||||
|
FROM domainlist
|
||||||
|
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
||||||
|
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
||||||
|
WHERE domainlist.enabled = 1 AND (domainlist_by_group.group_id IS NULL OR "group".enabled = 1)
|
||||||
|
AND domainlist.type = 0
|
||||||
|
ORDER BY domainlist.id;
|
||||||
|
|
||||||
|
DROP VIEW vw_blacklist;
|
||||||
|
CREATE VIEW vw_denylist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
||||||
|
FROM domainlist
|
||||||
|
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
||||||
|
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
||||||
|
WHERE domainlist.enabled = 1 AND (domainlist_by_group.group_id IS NULL OR "group".enabled = 1)
|
||||||
|
AND domainlist.type = 1
|
||||||
|
ORDER BY domainlist.id;
|
||||||
|
|
||||||
|
DROP VIEW vw_regex_whitelist;
|
||||||
|
CREATE VIEW vw_regex_allowlist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
||||||
|
FROM domainlist
|
||||||
|
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
||||||
|
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
||||||
|
WHERE domainlist.enabled = 1 AND (domainlist_by_group.group_id IS NULL OR "group".enabled = 1)
|
||||||
|
AND domainlist.type = 2
|
||||||
|
ORDER BY domainlist.id;
|
||||||
|
|
||||||
|
DROP VIEW vw_regex_blacklist;
|
||||||
|
CREATE VIEW vw_regex_denylist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
||||||
|
FROM domainlist
|
||||||
|
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
||||||
|
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
||||||
|
WHERE domainlist.enabled = 1 AND (domainlist_by_group.group_id IS NULL OR "group".enabled = 1)
|
||||||
|
AND domainlist.type = 3
|
||||||
|
ORDER BY domainlist.id;
|
||||||
|
|
||||||
|
UPDATE info SET value = 20 WHERE property = 'version';
|
||||||
|
|
||||||
|
COMMIT;
|
@ -672,7 +672,7 @@ dig_at() {
|
|||||||
local record_type="A"
|
local record_type="A"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Find a random blocked url that has not been whitelisted and is not ABP style.
|
# Find a random blocked url that has not been allowlisted and is not ABP style.
|
||||||
# This helps emulate queries to different domains that a user might query
|
# This helps emulate queries to different domains that a user might query
|
||||||
# It will also give extra assurance that Pi-hole is correctly resolving and blocking domains
|
# It will also give extra assurance that Pi-hole is correctly resolving and blocking domains
|
||||||
local random_url
|
local random_url
|
||||||
@ -1088,7 +1088,7 @@ show_adlists() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
show_domainlist() {
|
show_domainlist() {
|
||||||
show_db_entries "Domainlist (0/1 = exact white-/blacklist, 2/3 = regex white-/blacklist)" "SELECT id,CASE type WHEN '0' THEN '0 ' WHEN '1' THEN ' 1 ' WHEN '2' THEN ' 2 ' WHEN '3' THEN ' 3' ELSE type END type,CASE enabled WHEN '0' THEN ' 0' WHEN '1' THEN ' 1' ELSE enabled END enabled,GROUP_CONCAT(domainlist_by_group.group_id) group_ids,domain,datetime(date_added,'unixepoch','localtime') date_added,datetime(date_modified,'unixepoch','localtime') date_modified,comment FROM domainlist LEFT JOIN domainlist_by_group ON domainlist.id = domainlist_by_group.domainlist_id GROUP BY id;" "5 4 7 12 100 19 19 50"
|
show_db_entries "Domainlist (0/1 = exact allow-/denylist, 2/3 = regex allow-/denylist)" "SELECT id,CASE type WHEN '0' THEN '0 ' WHEN '1' THEN ' 1 ' WHEN '2' THEN ' 2 ' WHEN '3' THEN ' 3' ELSE type END type,CASE enabled WHEN '0' THEN ' 0' WHEN '1' THEN ' 1' ELSE enabled END enabled,GROUP_CONCAT(domainlist_by_group.group_id) group_ids,domain,datetime(date_added,'unixepoch','localtime') date_added,datetime(date_modified,'unixepoch','localtime') date_modified,comment FROM domainlist LEFT JOIN domainlist_by_group ON domainlist.id = domainlist_by_group.domainlist_id GROUP BY id;" "5 4 7 12 100 19 19 50"
|
||||||
}
|
}
|
||||||
|
|
||||||
show_clients() {
|
show_clients() {
|
||||||
|
@ -66,7 +66,7 @@ CREATE TABLE info
|
|||||||
value TEXT NOT NULL
|
value TEXT NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO "info" VALUES('version','19');
|
INSERT INTO "info" VALUES('version','20');
|
||||||
/* This is a flag to indicate if gravity was restored from a backup
|
/* This is a flag to indicate if gravity was restored from a backup
|
||||||
false = not restored,
|
false = not restored,
|
||||||
failed = restoration failed due to no backup
|
failed = restoration failed due to no backup
|
||||||
@ -111,7 +111,7 @@ CREATE TRIGGER tr_domainlist_update AFTER UPDATE ON domainlist
|
|||||||
UPDATE domainlist SET date_modified = (cast(strftime('%s', 'now') as int)) WHERE domain = NEW.domain;
|
UPDATE domainlist SET date_modified = (cast(strftime('%s', 'now') as int)) WHERE domain = NEW.domain;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
CREATE VIEW vw_whitelist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
CREATE VIEW vw_allowlist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
||||||
FROM domainlist
|
FROM domainlist
|
||||||
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
||||||
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
||||||
@ -119,7 +119,7 @@ CREATE VIEW vw_whitelist AS SELECT domain, domainlist.id AS id, domainlist_by_gr
|
|||||||
AND domainlist.type = 0
|
AND domainlist.type = 0
|
||||||
ORDER BY domainlist.id;
|
ORDER BY domainlist.id;
|
||||||
|
|
||||||
CREATE VIEW vw_blacklist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
CREATE VIEW vw_denylist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
||||||
FROM domainlist
|
FROM domainlist
|
||||||
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
||||||
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
||||||
@ -127,7 +127,7 @@ CREATE VIEW vw_blacklist AS SELECT domain, domainlist.id AS id, domainlist_by_gr
|
|||||||
AND domainlist.type = 1
|
AND domainlist.type = 1
|
||||||
ORDER BY domainlist.id;
|
ORDER BY domainlist.id;
|
||||||
|
|
||||||
CREATE VIEW vw_regex_whitelist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
CREATE VIEW vw_regex_allowlist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
||||||
FROM domainlist
|
FROM domainlist
|
||||||
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
||||||
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
||||||
@ -135,7 +135,7 @@ CREATE VIEW vw_regex_whitelist AS SELECT domain, domainlist.id AS id, domainlist
|
|||||||
AND domainlist.type = 2
|
AND domainlist.type = 2
|
||||||
ORDER BY domainlist.id;
|
ORDER BY domainlist.id;
|
||||||
|
|
||||||
CREATE VIEW vw_regex_blacklist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
CREATE VIEW vw_regex_denylist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
||||||
FROM domainlist
|
FROM domainlist
|
||||||
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
||||||
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
||||||
|
@ -851,7 +851,7 @@ gravity_Table_Count() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Output count of blacklisted domains and regex filters
|
# Output count of denied and allowed domains and regex filters
|
||||||
gravity_ShowCount() {
|
gravity_ShowCount() {
|
||||||
# Here we use the table "gravity" instead of the view "vw_gravity" for speed.
|
# Here we use the table "gravity" instead of the view "vw_gravity" for speed.
|
||||||
# It's safe to replace it here, because right after a gravity run both will show the exactly same number of domains.
|
# It's safe to replace it here, because right after a gravity run both will show the exactly same number of domains.
|
||||||
|
@ -268,7 +268,7 @@ Allow-/denylist manipulation
|
|||||||
|
|
||||||
\fBpihole --regex "ad.*\\.example\\.com$"\fR
|
\fBpihole --regex "ad.*\\.example\\.com$"\fR
|
||||||
.br
|
.br
|
||||||
Adds "ad.*\\.example\\.com$" to the regex blacklist.
|
Adds "ad.*\\.example\\.com$" to the regex denylist.
|
||||||
Would block all subdomains of example.com which start with "ad"
|
Would block all subdomains of example.com which start with "ad"
|
||||||
.br
|
.br
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user