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
|
@ -18,7 +18,7 @@ upgrade_gravityDB(){
|
||||||
|
|
||||||
if [[ "$version" == "1" ]]; then
|
if [[ "$version" == "1" ]]; then
|
||||||
# This migration script upgrades the gravity.db file by
|
# 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"
|
sqlite3 "${database}" < "/etc/.pihole/advanced/Scripts/database_migration/gravity/1_to_2.sql"
|
||||||
version=2
|
version=2
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ upgrade_gravityDB(){
|
||||||
if [ -e "${auditFile}" ]; then
|
if [ -e "${auditFile}" ]; then
|
||||||
echo -e " ${INFO} Migrating content of ${auditFile} into new database"
|
echo -e " ${INFO} Migrating content of ${auditFile} into new database"
|
||||||
# database_table_from_file is defined in gravity.sh
|
# 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
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
CREATE TABLE domain_auditlist
|
CREATE TABLE domain_audit
|
||||||
(
|
(
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
domain TEXT UNIQUE NOT NULL,
|
domain TEXT UNIQUE NOT NULL,
|
||||||
|
|
|
@ -557,23 +557,27 @@ addAudit()
|
||||||
shift # skip "-a"
|
shift # skip "-a"
|
||||||
shift # skip "audit"
|
shift # skip "audit"
|
||||||
local domains validDomain
|
local domains validDomain
|
||||||
domains="('$(checkDomain "${1}")')"
|
domains=""
|
||||||
shift # skip first domain, as it has already been added
|
|
||||||
for domain in "$@"
|
for domain in "$@"
|
||||||
do
|
do
|
||||||
# Insert only the domain here. The date_added field will be
|
# Insert only the domain here. The date_added field will be
|
||||||
# filled with its default value (date_added = current timestamp)
|
# filled with its default value (date_added = current timestamp)
|
||||||
validDomain="$(checkDomain "${domain}")"
|
validDomain="$(checkDomain "${domain}")"
|
||||||
if [[ -n "${validDomain}" ]]; then
|
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
|
fi
|
||||||
done
|
done
|
||||||
sqlite3 "${gravityDBfile}" "INSERT INTO \"domain_auditlist\" (domain) VALUES ${domains};"
|
sqlite3 "${gravityDBfile}" "INSERT INTO \"domain_audit\" (domain) VALUES ${domains};"
|
||||||
}
|
}
|
||||||
|
|
||||||
clearAudit()
|
clearAudit()
|
||||||
{
|
{
|
||||||
sqlite3 "${gravityDBfile}" "DELETE FROM \"domain_auditlist\";"
|
sqlite3 "${gravityDBfile}" "DELETE FROM \"domain_audit\";"
|
||||||
}
|
}
|
||||||
|
|
||||||
SetPrivacyLevel() {
|
SetPrivacyLevel() {
|
||||||
|
|
Loading…
Reference in New Issue