From 79111aea02a0f0e9ad677f2b6e8de37923b4aed7 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 14 Jan 2025 17:57:27 +0000 Subject: [PATCH 1/6] Now that FTL has a native config migration option - we no longer need to defer the startup of FTL as we were previously doing. Signed-off-by: Adam Warner --- src/bash_functions.sh | 17 ++++++++++++++++- src/start.sh | 26 +++++++++----------------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/bash_functions.sh b/src/bash_functions.sh index 6f2f72a..9c99d63 100644 --- a/src/bash_functions.sh +++ b/src/bash_functions.sh @@ -147,7 +147,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 +168,21 @@ 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 + printf "%b" "${FTLoutput}" | sed 's/^/ /' | sed 's/ Migrating config to Pi-hole v6.0 format/ [i] Migrating config to Pi-hole v6.0 format/' + + # Print a blank line for separation + echo "" } setup_web_password() { diff --git a/src/start.sh b/src/start.sh index da6afad..4bc9094 100644 --- a/src/start.sh +++ b/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 @@ -88,11 +80,11 @@ start() { # 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 + # if [[ ${v5_volume} -eq 1 ]]; then + # echo " [i] Starting deferred FTL Configuration" + # ftl_config + # echo "" + # fi pihole updatechecker pihole -v From b6b2a46826634f0d631b97d7a0c5959207236b4a Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 14 Jan 2025 18:19:40 +0000 Subject: [PATCH 2/6] Further tweaks to output - offset gravity schema upgrade messages to fit with the container output. Supress message in FTL migration output about environment variables, as these are not read in until FTLs first proper start Signed-off-by: Adam Warner --- src/bash_functions.sh | 9 ++++++--- src/start.sh | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/bash_functions.sh b/src/bash_functions.sh index 9c99d63..37b35f6 100644 --- a/src/bash_functions.sh +++ b/src/bash_functions.sh @@ -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 "" } @@ -179,7 +181,8 @@ migrate_v5_configs() { # 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 - printf "%b" "${FTLoutput}" | sed 's/^/ /' | sed 's/ Migrating config to Pi-hole v6.0 format/ [i] Migrating config to Pi-hole v6.0 format/' + # We supress 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 "" diff --git a/src/start.sh b/src/start.sh index 4bc9094..862e78f 100644 --- a/src/start.sh +++ b/src/start.sh @@ -87,7 +87,10 @@ start() { # 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 From 5b62938371f999df022a431c6271e784ffcbb6ee Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 14 Jan 2025 18:29:22 +0000 Subject: [PATCH 3/6] quiet, codespell --- src/bash_functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bash_functions.sh b/src/bash_functions.sh index 37b35f6..7da0554 100644 --- a/src/bash_functions.sh +++ b/src/bash_functions.sh @@ -181,7 +181,7 @@ migrate_v5_configs() { # 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 supress the message about environment variables as these will be set on FTL's first real start + # 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 From 2be014f06676c05b15e49f87a0591d71f431766f Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Thu, 30 Jan 2025 19:20:44 +0000 Subject: [PATCH 4/6] Remove some redundant commented out code Signed-off-by: Adam Warner --- src/start.sh | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/start.sh b/src/start.sh index 862e78f..a5153da 100644 --- a/src/start.sh +++ b/src/start.sh @@ -77,15 +77,7 @@ start() { while ! grep -q '########## FTL started' /var/log/pihole/FTL.log; do 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 local versionsOutput versionsOutput=$(pihole -v) From d13692ba195562b75ebda7f0b56d9701262ef0e1 Mon Sep 17 00:00:00 2001 From: yubiuser Date: Mon, 10 Feb 2025 17:11:42 +0100 Subject: [PATCH 5/6] Amend Readme regarding /etc-dnsmasq.d Signed-off-by: yubiuser --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index db388db..dbdbd4d 100644 --- a/README.md +++ b/README.md @@ -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 used it before your should keep it enabled at the first v6 container start for a complete migration. Can be turned off afterwards. #- './etc-dnsmasq.d:/etc/dnsmasq.d' cap_add: # See https://github.com/pi-hole/docker-pi-hole#note-on-capabilities From 75938e67981c92039569b7ea049f57321292768b Mon Sep 17 00:00:00 2001 From: yubiuser Date: Mon, 10 Feb 2025 17:21:42 +0100 Subject: [PATCH 6/6] Improve wording Co-authored-by: Adam Warner Signed-off-by: yubiuser --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dbdbd4d..9bc6b85 100644 --- a/README.md +++ b/README.md @@ -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 starting fresh with Pi-hole v6. If you're upgrading from v5 you and used it before your should keep it enabled at the first v6 container start for a complete migration. Can be turned off afterwards. + # 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