mirror of
https://github.com/pi-hole/docker-pi-hole.git
synced 2025-12-20 02:18:51 +00:00
Merge pull request #1683 from pi-hole/explicit-migrate
Utilise FTL's native config upgrade functionality
This commit is contained in:
@@ -76,7 +76,7 @@ services:
|
||||
volumes:
|
||||
# For persisting Pi-hole's databases and common configuration file
|
||||
- './etc-pihole:/etc/pihole'
|
||||
# Uncomment the below if you have custom dnsmasq config files that you want to persist. Not needed for most.
|
||||
# Uncomment the below if you have custom dnsmasq config files that you want to persist. Not needed for most starting fresh with Pi-hole v6. If you're upgrading from v5 you and have used this directory before, you should keep it enabled for the first v6 container start to allow for a complete migration. It can be removed afterwards
|
||||
#- './etc-dnsmasq.d:/etc/dnsmasq.d'
|
||||
cap_add:
|
||||
# See https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
|
||||
|
||||
@@ -116,10 +116,12 @@ migrate_gravity() {
|
||||
echo " [i] Gravity will now be run to create the database"
|
||||
pihole -g
|
||||
else
|
||||
echo " [i] Existing gravity database found"
|
||||
echo " [i] Existing gravity database found - schema will be upgraded if necessary"
|
||||
# source the migration script and run the upgrade function
|
||||
source /etc/.pihole/advanced/Scripts/database_migration/gravity-db.sh
|
||||
upgrade_gravityDB "${gravityDBfile}" "/etc/pihole"
|
||||
local upgradeOutput
|
||||
upgradeOutput=$(upgrade_gravityDB "${gravityDBfile}" "/etc/pihole")
|
||||
printf "%b" "${upgradeOutput}\\n" | sed 's/^/ /'
|
||||
fi
|
||||
echo ""
|
||||
}
|
||||
@@ -147,7 +149,7 @@ ftl_config() {
|
||||
setup_web_password
|
||||
}
|
||||
|
||||
migrate_dnsmasq_d_contents() {
|
||||
migrate_v5_configs() {
|
||||
# Previously, Pi-hole created a number of files in /etc/dnsmasq.d
|
||||
# During migration, their content is copied into the new single source of
|
||||
# truth file /etc/pihole/pihole.toml and the old files are moved away to
|
||||
@@ -168,6 +170,22 @@ migrate_dnsmasq_d_contents() {
|
||||
mv /etc/dnsmasq.d/0{1,2,4,5}-pihole*.conf "${V6_CONF_MIGRATION_DIR}/" 2>/dev/null || true
|
||||
mv /etc/dnsmasq.d/06-rfc6761.conf "${V6_CONF_MIGRATION_DIR}/" 2>/dev/null || true
|
||||
echo ""
|
||||
|
||||
# Finally, after everything is in place, we can create the new config file
|
||||
# /etc/pihole/pihole.toml
|
||||
# This file will be created with the default settings unless the user has
|
||||
# changed settings via setupVars.conf or the other dnsmasq files moved above
|
||||
# During migration, setupVars.conf is moved to /etc/pihole/migration_backup_v6
|
||||
local FTLoutput
|
||||
FTLoutput=$(pihole-FTL migrate v6)
|
||||
|
||||
# Print the output of the FTL migration prefacing every line with six
|
||||
# spaces for alignment with other container output. Replace the first line to match the style of the other messages
|
||||
# We suppress the message about environment variables as these will be set on FTL's first real start
|
||||
printf "%b" "${FTLoutput}\\n" | sed 's/^/ /' | sed 's/ Migrating config to Pi-hole v6.0 format/ [i] Migrating config to Pi-hole v6.0 format/' | sed 's/- 0 entries are forced through environment//'
|
||||
|
||||
# Print a blank line for separation
|
||||
echo ""
|
||||
}
|
||||
|
||||
setup_web_password() {
|
||||
|
||||
29
src/start.sh
29
src/start.sh
@@ -21,13 +21,8 @@ start() {
|
||||
# FTL Will handle the migration of the config files
|
||||
if [[ -f /etc/pihole/setupVars.conf && ! -f /etc/pihole/pihole.toml ]]; then
|
||||
echo " [i] v5 files detected that have not yet been migrated to v6"
|
||||
echo " [i] Deferring additional configuration until after FTL has started"
|
||||
echo " [i] Note: It is normal to see \"Config file /etc/pihole/pihole.toml not available (r): No such file or directory\" in the logs at this point"
|
||||
echo ""
|
||||
# We need to migrate the dnsmasq.d contents so that FTL can read them in properly
|
||||
migrate_dnsmasq_d_contents
|
||||
v5_volume=1
|
||||
|
||||
migrate_v5_configs
|
||||
fi
|
||||
|
||||
# ===========================
|
||||
@@ -37,12 +32,9 @@ start() {
|
||||
# If PIHOLE_UID is set, modify the pihole user's id to match
|
||||
set_uid_gid
|
||||
|
||||
# Only run the next step if we are not migrating from v5 to v6
|
||||
if [[ ${v5_volume} -eq 0 ]]; then
|
||||
# Configure FTL with any environment variables if needed
|
||||
echo " [i] Starting FTL configuration"
|
||||
ftl_config
|
||||
fi
|
||||
# Configure FTL with any environment variables if needed
|
||||
echo " [i] Starting FTL configuration"
|
||||
ftl_config
|
||||
|
||||
# Install additional packages inside the container if requested
|
||||
install_additional_packages
|
||||
@@ -86,16 +78,11 @@ start() {
|
||||
sleep 0.5
|
||||
done
|
||||
|
||||
# If we are migrating from v5 to v6, we now need to run the basic configuration step that we deferred earlier
|
||||
# This is because pihole-FTL needs to migrate the config files before we can perform the basic configuration checks
|
||||
if [[ ${v5_volume} -eq 1 ]]; then
|
||||
echo " [i] Starting deferred FTL Configuration"
|
||||
ftl_config
|
||||
echo ""
|
||||
fi
|
||||
|
||||
pihole updatechecker
|
||||
pihole -v
|
||||
local versionsOutput
|
||||
versionsOutput=$(pihole -v)
|
||||
echo " [i] Version info:"
|
||||
printf "%b" "${versionsOutput}\\n" | sed 's/^/ /'
|
||||
echo ""
|
||||
|
||||
if [ "${TAIL_FTL_LOG:-1}" -eq 1 ]; then
|
||||
|
||||
Reference in New Issue
Block a user