From b39ecb0f971bfeae458911af26cb0a8d55684e4f Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 14 Jan 2025 17:57:27 +0000 Subject: [PATCH 1/4] 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 3a82717d..3491f8a9 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 da6afad0..4bc90942 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 21756bec2657ddf0573a50c679e5d4f958a7cd7a Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 14 Jan 2025 18:19:40 +0000 Subject: [PATCH 2/4] 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 3491f8a9..6857fa04 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 4bc90942..862e78f2 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 e1eb2dfff50199f812df8fb41142a8f9bfc2353c Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 14 Jan 2025 18:29:22 +0000 Subject: [PATCH 3/4] 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 6857fa04..58f7f83b 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 6d93bb00ae40e24c67c626c775fe068168d19705 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Thu, 30 Jan 2025 19:20:44 +0000 Subject: [PATCH 4/4] 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 862e78f2..a5153da1 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)