mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Only migrate legacy list files when we create gravity.db in the same gravity run
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
parent
2f698904e4
commit
008e88b84b
1 changed files with 26 additions and 25 deletions
21
gravity.sh
21
gravity.sh
|
@ -93,12 +93,6 @@ database_table_from_file() {
|
|||
backup_path="${piholeDir}/migration_backup"
|
||||
backup_file="${backup_path}/$(basename "${2}")"
|
||||
|
||||
# Create database file if not present
|
||||
if [ ! -e "${gravityDBfile}" ]; then
|
||||
echo -e " ${INFO} Creating new gravity database"
|
||||
generate_gravity_database
|
||||
fi
|
||||
|
||||
# Truncate table
|
||||
output=$( { sqlite3 "${gravityDBfile}" <<< "DELETE FROM ${table};"; } 2>&1 )
|
||||
status="$?"
|
||||
|
@ -155,26 +149,33 @@ database_table_from_file() {
|
|||
|
||||
# Migrate pre-v5.0 list files to database-based Pi-hole versions
|
||||
migrate_to_database() {
|
||||
# Create database file if not present
|
||||
if [ ! -e "${gravityDBfile}" ]; then
|
||||
echo -e " ${INFO} Creating new gravity database"
|
||||
generate_gravity_database
|
||||
|
||||
# Migrate list files to new database
|
||||
if [[ -e "${adListFile}" ]]; then
|
||||
# Store adlists domains in database
|
||||
echo -e " ${INFO} Pi-hole upgrade: Moving content of ${adListFile} into database"
|
||||
echo -e " ${INFO} Migrating content of ${adListFile} into new database"
|
||||
database_table_from_file "adlists" "${adListFile}"
|
||||
fi
|
||||
if [[ -e "${blacklistFile}" ]]; then
|
||||
# Store blacklisted domains in database
|
||||
echo -e " ${INFO} Pi-hole upgrade: Moving content of ${blacklistFile} into database"
|
||||
echo -e " ${INFO} Migrating content of ${blacklistFile} into new database"
|
||||
database_table_from_file "blacklist" "${blacklistFile}"
|
||||
fi
|
||||
if [[ -e "${whitelistFile}" ]]; then
|
||||
# Store whitelisted domains in database
|
||||
echo -e " ${INFO} Pi-hole upgrade: Moving content of ${whitelistFile} into database"
|
||||
echo -e " ${INFO} Migrating content of ${whitelistFile} into new database"
|
||||
database_table_from_file "whitelist" "${whitelistFile}"
|
||||
fi
|
||||
if [[ -e "${regexFile}" ]]; then
|
||||
# Store regex domains in database
|
||||
echo -e " ${INFO} Pi-hole upgrade: Moving content of ${regexFile} into database"
|
||||
echo -e " ${INFO} Migrating content of ${regexFile} into new database"
|
||||
database_table_from_file "regex" "${regexFile}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Determine if DNS resolution is available before proceeding
|
||||
|
|
Loading…
Reference in a new issue