mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-04-22 15:20:14 +00:00
Merge branch 'development' into packages
This commit is contained in:
commit
c380c23592
9 changed files with 42 additions and 50 deletions
|
@ -13,10 +13,9 @@
|
|||
readonly scriptPath="/etc/.pihole/advanced/Scripts/database_migration/gravity"
|
||||
|
||||
upgrade_gravityDB(){
|
||||
local database piholeDir auditFile version
|
||||
local database piholeDir version
|
||||
database="${1}"
|
||||
piholeDir="${2}"
|
||||
auditFile="${piholeDir}/auditlog.list"
|
||||
|
||||
# Exit early if the database does not exist (e.g. in CI tests)
|
||||
if [[ ! -f "${database}" ]]; then
|
||||
|
@ -27,18 +26,11 @@ upgrade_gravityDB(){
|
|||
version="$(pihole-FTL sqlite3 -ni "${database}" "SELECT \"value\" FROM \"info\" WHERE \"property\" = 'version';")"
|
||||
|
||||
if [[ "$version" == "1" ]]; then
|
||||
# This migration script upgrades the gravity.db file by
|
||||
# adding the domain_audit table
|
||||
# This migration script upgraded the gravity.db file by
|
||||
# adding the domain_audit table. It is now a no-op
|
||||
echo -e " ${INFO} Upgrading gravity database from version 1 to 2"
|
||||
pihole-FTL sqlite3 -ni "${database}" < "${scriptPath}/1_to_2.sql"
|
||||
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
|
||||
if [[ "$version" == "2" ]]; then
|
||||
# This migration script upgrades the gravity.db file by
|
||||
|
|
|
@ -2,13 +2,6 @@
|
|||
|
||||
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';
|
||||
|
||||
COMMIT;
|
||||
|
|
|
@ -32,7 +32,7 @@ flushARP(){
|
|||
fi
|
||||
|
||||
# Stop FTL to prevent database access
|
||||
if ! output=$(pihole-FTL service stop 2>&1); then
|
||||
if ! output=$(service pihole-FTL stop 2>&1); then
|
||||
echo -e "${OVER} ${CROSS} Failed to stop FTL"
|
||||
echo " Output: ${output}"
|
||||
return 1
|
||||
|
@ -64,7 +64,7 @@ flushARP(){
|
|||
fi
|
||||
|
||||
# Start FTL again
|
||||
if ! output=$(pihole-FTL service restart 2>&1); then
|
||||
if ! output=$(service pihole-FTL restart 2>&1); then
|
||||
echo -e "${OVER} ${CROSS} Failed to restart FTL"
|
||||
echo " Output: ${output}"
|
||||
return 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue