mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-23 14:43:42 +00:00
Remove remaining traces of audit log (#5817)
This commit is contained in:
commit
6b423f534c
5 changed files with 4 additions and 30 deletions
|
@ -13,10 +13,9 @@
|
||||||
readonly scriptPath="/etc/.pihole/advanced/Scripts/database_migration/gravity"
|
readonly scriptPath="/etc/.pihole/advanced/Scripts/database_migration/gravity"
|
||||||
|
|
||||||
upgrade_gravityDB(){
|
upgrade_gravityDB(){
|
||||||
local database piholeDir auditFile version
|
local database piholeDir version
|
||||||
database="${1}"
|
database="${1}"
|
||||||
piholeDir="${2}"
|
piholeDir="${2}"
|
||||||
auditFile="${piholeDir}/auditlog.list"
|
|
||||||
|
|
||||||
# Exit early if the database does not exist (e.g. in CI tests)
|
# Exit early if the database does not exist (e.g. in CI tests)
|
||||||
if [[ ! -f "${database}" ]]; then
|
if [[ ! -f "${database}" ]]; then
|
||||||
|
@ -27,18 +26,11 @@ upgrade_gravityDB(){
|
||||||
version="$(pihole-FTL sqlite3 -ni "${database}" "SELECT \"value\" FROM \"info\" WHERE \"property\" = 'version';")"
|
version="$(pihole-FTL sqlite3 -ni "${database}" "SELECT \"value\" FROM \"info\" WHERE \"property\" = 'version';")"
|
||||||
|
|
||||||
if [[ "$version" == "1" ]]; then
|
if [[ "$version" == "1" ]]; then
|
||||||
# This migration script upgrades the gravity.db file by
|
# This migration script upgraded the gravity.db file by
|
||||||
# adding the domain_audit table
|
# adding the domain_audit table. It is now a no-op
|
||||||
echo -e " ${INFO} Upgrading gravity database from version 1 to 2"
|
echo -e " ${INFO} Upgrading gravity database from version 1 to 2"
|
||||||
pihole-FTL sqlite3 -ni "${database}" < "${scriptPath}/1_to_2.sql"
|
pihole-FTL sqlite3 -ni "${database}" < "${scriptPath}/1_to_2.sql"
|
||||||
version=2
|
version=2
|
||||||
|
|
||||||
# Store audit domains in database table
|
|
||||||
if [ -e "${auditFile}" ]; then
|
|
||||||
echo -e " ${INFO} Migrating content of ${auditFile} into new database"
|
|
||||||
# database_table_from_file is defined in gravity.sh
|
|
||||||
database_table_from_file "domain_audit" "${auditFile}"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
if [[ "$version" == "2" ]]; then
|
if [[ "$version" == "2" ]]; then
|
||||||
# This migration script upgrades the gravity.db file by
|
# This migration script upgrades the gravity.db file by
|
||||||
|
|
|
@ -2,13 +2,6 @@
|
||||||
|
|
||||||
BEGIN TRANSACTION;
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
CREATE TABLE domain_audit
|
|
||||||
(
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
domain TEXT UNIQUE NOT NULL,
|
|
||||||
date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int))
|
|
||||||
);
|
|
||||||
|
|
||||||
UPDATE info SET value = 2 WHERE property = 'version';
|
UPDATE info SET value = 2 WHERE property = 'version';
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
|
@ -68,13 +68,6 @@ CREATE TABLE info
|
||||||
|
|
||||||
INSERT INTO "info" VALUES('version','19');
|
INSERT INTO "info" VALUES('version','19');
|
||||||
|
|
||||||
CREATE TABLE domain_audit
|
|
||||||
(
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
domain TEXT UNIQUE NOT NULL,
|
|
||||||
date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int))
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE domainlist_by_group
|
CREATE TABLE domainlist_by_group
|
||||||
(
|
(
|
||||||
domainlist_id INTEGER NOT NULL REFERENCES domainlist (id),
|
domainlist_id INTEGER NOT NULL REFERENCES domainlist (id),
|
||||||
|
|
|
@ -9,7 +9,6 @@ DROP TRIGGER tr_client_add;
|
||||||
DROP TRIGGER tr_adlist_add;
|
DROP TRIGGER tr_adlist_add;
|
||||||
|
|
||||||
INSERT OR REPLACE INTO "group" SELECT * FROM OLD."group";
|
INSERT OR REPLACE INTO "group" SELECT * FROM OLD."group";
|
||||||
INSERT OR REPLACE INTO domain_audit SELECT * FROM OLD.domain_audit;
|
|
||||||
|
|
||||||
INSERT OR REPLACE INTO domainlist SELECT * FROM OLD.domainlist;
|
INSERT OR REPLACE INTO domainlist SELECT * FROM OLD.domainlist;
|
||||||
DELETE FROM OLD.domainlist_by_group WHERE domainlist_id NOT IN (SELECT id FROM OLD.domainlist);
|
DELETE FROM OLD.domainlist_by_group WHERE domainlist_id NOT IN (SELECT id FROM OLD.domainlist);
|
||||||
|
|
|
@ -172,10 +172,7 @@ database_table_from_file() {
|
||||||
grep -v '^ *#' <"${src}" | while IFS= read -r domain; do
|
grep -v '^ *#' <"${src}" | while IFS= read -r domain; do
|
||||||
# Only add non-empty lines
|
# Only add non-empty lines
|
||||||
if [[ -n "${domain}" ]]; then
|
if [[ -n "${domain}" ]]; then
|
||||||
if [[ "${table}" == "domain_audit" ]]; then
|
if [[ "${table}" == "adlist" ]]; then
|
||||||
# domain_audit table format (no enable or modified fields)
|
|
||||||
echo "${rowid},\"${domain}\",${timestamp}" >>"${tmpFile}"
|
|
||||||
elif [[ "${table}" == "adlist" ]]; then
|
|
||||||
# Adlist table format
|
# Adlist table format
|
||||||
echo "${rowid},\"${domain}\",1,${timestamp},${timestamp},\"Migrated from ${src}\",,0,0,0,0,0" >>"${tmpFile}"
|
echo "${rowid},\"${domain}\",1,${timestamp},${timestamp},\"Migrated from ${src}\",,0,0,0,0,0" >>"${tmpFile}"
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue