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