Rename table to "auditlist"

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2019-07-05 16:28:36 +02:00
parent 82476138c1
commit 2fb4256f84
No known key found for this signature in database
GPG key ID: 00135ACBD90B28DD
4 changed files with 9 additions and 10 deletions

View file

@ -1,4 +1,4 @@
CREATE TABLE audit CREATE TABLE auditlist
( (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
domain TEXT UNIQUE NOT NULL, domain TEXT UNIQUE NOT NULL,

View file

@ -554,12 +554,12 @@ addAudit()
# filled with its default value (date_added = current timestamp) # filled with its default value (date_added = current timestamp)
domains="${domains},('${domain}')" domains="${domains},('${domain}')"
done done
sqlite3 "${gravityDBfile}" "INSERT INTO \"audit\" (domain) VALUES ${domains};" sqlite3 "${gravityDBfile}" "INSERT INTO \"auditlist\" (domain) VALUES ${domains};"
} }
clearAudit() clearAudit()
{ {
sqlite3 "${gravityDBfile}" "DELETE FROM \"audit\";" sqlite3 "${gravityDBfile}" "DELETE FROM \"auditlist\";"
} }
SetPrivacyLevel() { SetPrivacyLevel() {

View file

@ -81,12 +81,11 @@ CREATE TABLE gravity
domain TEXT PRIMARY KEY domain TEXT PRIMARY KEY
); );
CREATE TABLE audit CREATE TABLE auditlist
( (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
domain TEXT UNIQUE NOT NULL, domain TEXT UNIQUE NOT NULL,
date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)), date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int))
comment TEXT
); );
CREATE TABLE info CREATE TABLE info

View file

@ -30,7 +30,7 @@ whitelistFile="${piholeDir}/whitelist.txt"
blacklistFile="${piholeDir}/blacklist.txt" blacklistFile="${piholeDir}/blacklist.txt"
regexFile="${piholeDir}/regex.list" regexFile="${piholeDir}/regex.list"
adListFile="${piholeDir}/adlists.list" adListFile="${piholeDir}/adlists.list"
auditFile="${piholeDir}/audit.list" auditFile="${piholeDir}/auditlog.list"
localList="${piholeDir}/local.list" localList="${piholeDir}/local.list"
VPNList="/etc/openvpn/ipp.txt" VPNList="/etc/openvpn/ipp.txt"
@ -119,12 +119,12 @@ database_table_from_file() {
declare -i rowid declare -i rowid
rowid=1 rowid=1
# Read file line by line # Read file line by line
if [[ "${table}" == "audit" ]]; then if [[ "${table}" == "auditlist" ]]; then
grep -v '^ *#' < "${source}" | while IFS= read -r domain grep -v '^ *#' < "${source}" | while IFS= read -r domain
do do
# Only add non-empty lines # Only add non-empty lines
if [[ ! -z "${domain}" ]]; then if [[ ! -z "${domain}" ]]; then
# Audit table format # Auditlist table format
echo "${rowid},\"${domain}\",${timestamp}" >> "${tmpFile}" echo "${rowid},\"${domain}\",${timestamp}" >> "${tmpFile}"
rowid+=1 rowid+=1
fi fi
@ -198,7 +198,7 @@ migrate_to_database() {
if [ -e "${auditFile}" ]; then if [ -e "${auditFile}" ]; then
# Store audit domains in database # Store audit domains in database
echo -e " ${INFO} Migrating content of ${auditFile} into new database" echo -e " ${INFO} Migrating content of ${auditFile} into new database"
database_table_from_file "audit" "${auditFile}" database_table_from_file "auditlist" "${auditFile}"
fi fi
} }