mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Rename table to domain_audit and simplify subroutine addAudit().
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
parent
be3e198f9a
commit
8382f4d727
3 changed files with 12 additions and 8 deletions
|
@ -18,7 +18,7 @@ upgrade_gravityDB(){
|
|||
|
||||
if [[ "$version" == "1" ]]; then
|
||||
# This migration script upgrades the gravity.db file by
|
||||
# adding the domain_auditlist table
|
||||
# adding the domain_audit table
|
||||
sqlite3 "${database}" < "/etc/.pihole/advanced/Scripts/database_migration/gravity/1_to_2.sql"
|
||||
version=2
|
||||
|
||||
|
@ -26,7 +26,7 @@ upgrade_gravityDB(){
|
|||
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_auditlist" "${auditFile}"
|
||||
database_table_from_file "domain_audit" "${auditFile}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE domain_auditlist
|
||||
CREATE TABLE domain_audit
|
||||
(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
domain TEXT UNIQUE NOT NULL,
|
||||
|
|
|
@ -557,23 +557,27 @@ addAudit()
|
|||
shift # skip "-a"
|
||||
shift # skip "audit"
|
||||
local domains validDomain
|
||||
domains="('$(checkDomain "${1}")')"
|
||||
shift # skip first domain, as it has already been added
|
||||
domains=""
|
||||
for domain in "$@"
|
||||
do
|
||||
# Insert only the domain here. The date_added field will be
|
||||
# filled with its default value (date_added = current timestamp)
|
||||
validDomain="$(checkDomain "${domain}")"
|
||||
if [[ -n "${validDomain}" ]]; then
|
||||
domains="${domains},('${domain}')"
|
||||
# Put comma in between () when there is
|
||||
# more than one domains to be added
|
||||
if [[ -n "${domains}" ]]; then
|
||||
domains="${domains},"
|
||||
fi
|
||||
domains="${domains}('${domain}')"
|
||||
fi
|
||||
done
|
||||
sqlite3 "${gravityDBfile}" "INSERT INTO \"domain_auditlist\" (domain) VALUES ${domains};"
|
||||
sqlite3 "${gravityDBfile}" "INSERT INTO \"domain_audit\" (domain) VALUES ${domains};"
|
||||
}
|
||||
|
||||
clearAudit()
|
||||
{
|
||||
sqlite3 "${gravityDBfile}" "DELETE FROM \"domain_auditlist\";"
|
||||
sqlite3 "${gravityDBfile}" "DELETE FROM \"domain_audit\";"
|
||||
}
|
||||
|
||||
SetPrivacyLevel() {
|
||||
|
|
Loading…
Reference in a new issue