From bd3a0f4891818c16950e9348b5d6c225da5a88d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Sat, 22 Feb 2025 07:16:28 +0100 Subject: [PATCH 1/5] Don't set a random password on v5 -> v6 updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- automated install/basic-install.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 3bf14cc5..4f30bf46 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -93,6 +93,7 @@ IPV6_ADDRESS=${IPV6_ADDRESS} QUERY_LOGGING= WEBPORT= PRIVACY_LEVEL= +v5_to_v6_update=false # Where old configs go to if a v6 migration is performed V6_CONF_MIGRATION_DIR="/etc/pihole/migration_backup_v6" @@ -2356,6 +2357,8 @@ migrate_dnsmasq_configs() { # Print a blank line for separation printf "\\n" + + v5_to_v6_update=true } # Check for availability of either the "service" or "systemctl" commands @@ -2515,18 +2518,11 @@ main() { # Copy the temp log file into final log location for storage copy_to_install_log - # Add password to web UI if there is none - pw="" - # If no password is set, - if [[ -z $(pihole-FTL --config webserver.api.pwhash) ]]; then - # generate a random password - pw=$(tr -dc _A-Z-a-z-0-9 Date: Sat, 22 Feb 2025 11:53:16 +0100 Subject: [PATCH 2/5] Print a more helpful message on pihole checkout in docker containers Signed-off-by: DL6ER --- pihole | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pihole b/pihole index 6424c793..b5fae016 100755 --- a/pihole +++ b/pihole @@ -398,7 +398,10 @@ tailFunc() { piholeCheckoutFunc() { if [ -n "${DOCKER_VERSION}" ]; then - unsupportedFunc + echo -e "${CROSS} Function not supported in Docker images" + echo "Please build a custom image following the steps at" + echo "https://github.com/pi-hole/docker-pi-hole?tab=readme-ov-file#building-the-image-locally" + exit 0 else if [[ "$2" == "-h" ]] || [[ "$2" == "--help" ]]; then echo "Switch Pi-hole subsystems to a different GitHub branch From 1764f993333c9a4b51132b84ebe3c74d19bd61c6 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sat, 22 Feb 2025 15:35:05 +0000 Subject: [PATCH 3/5] decide migration based on existence of setupVars rather than pihole.toml Signed-off-by: Adam Warner --- automated install/basic-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 4f30bf46..a3818147 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -2312,8 +2312,8 @@ migrate_dnsmasq_configs() { # avoid conflicts with other services on this system # Exit early if this is already Pi-hole v6.0 - # We decide this on the presence of the file /etc/pihole/pihole.toml - if [[ -f "${PI_HOLE_V6_CONFIG}" ]]; then + # We decide this on the non-existence of the file /etc/pihole/setupVars.conf (either moved by previous migration or fresh install) + if [[ ! -f "/etc/pihole/setupVars.conf" ]]; then return 0 fi From 8f5296536e682ec169e11e4cb361cd60d39f74b4 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Sat, 22 Feb 2025 15:41:46 +0100 Subject: [PATCH 4/5] Fix dnsmasq v5 to v6 config migration The dnsmasq config files were removed in `remove_old_dnsmasq_ftl_configs()`, before they were tried to be migrated via `migrate_dnsmasq_configs()`, and hence most settings were lost during v5 to v6 update. This commit renames and adjussts `remove_old_dnsmasq_ftl_configs()` to move dnsmasq config files into the migration directory instead, to be picked up by `migrate_dnsmasq_configs()` later. Signed-off-by: MichaIng --- automated install/basic-install.sh | 60 +++++++++++------------------- 1 file changed, 21 insertions(+), 39 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index a3818147..3680cff3 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1161,27 +1161,23 @@ installDefaultBlocklists() { echo "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" >>"${adlistFile}" } -remove_old_dnsmasq_ftl_configs() { - # Local, named variables +move_old_dnsmasq_ftl_configs() { + # Create migration directory /etc/pihole/migration_backup_v6 + # and make it owned by pihole:pihole + mkdir -p "${V6_CONF_MIGRATION_DIR}" + chown pihole:pihole "${V6_CONF_MIGRATION_DIR}" + + # Move all conf files originally created by Pi-hole into this directory + # - 01-pihole.conf + # - 02-pihole-dhcp.conf + # - 04-pihole-static-dhcp.conf + # - 05-pihole-custom-cname.conf + # - 06-rfc6761.conf + 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 + + # If the dnsmasq main config file exists local dnsmasq_conf="/etc/dnsmasq.conf" - local pihole_01="/etc/dnsmasq.d/01-pihole.conf" - local rfc6761_06="/etc/dnsmasq.d/06-rfc6761.conf" - local pihole_dhcp_02="/etc/dnsmasq.d/02-pihole-dhcp.conf" - - # pihole-FTL does some fancy stuff with config these days, and so we can remove some old config files - if [[ -f "${pihole_01}" ]]; then - rm "${pihole_01}" - fi - - if [[ -f "${rfc6761_06}" ]]; then - rm "${rfc6761_06}" - fi - - if [[ -f "${pihole_dhcp_02}" ]]; then - rm "${pihole_dhcp_02}" - fi - - # If the dnsmasq config file exists if [[ -f "${dnsmasq_conf}" ]]; then # There should not be anything custom in here for Pi-hole users # It is no longer needed, but we'll back it up instead of deleting it just in case @@ -1695,7 +1691,8 @@ installPihole() { exit 1 fi - remove_old_dnsmasq_ftl_configs + # Move old dnsmasq files to $V6_CONF_MIGRATION_DIR for later migration via migrate_dnsmasq_configs() + move_old_dnsmasq_ftl_configs remove_old_pihole_lighttpd_configs # Install config files @@ -2320,25 +2317,10 @@ migrate_dnsmasq_configs() { # Disable lighttpd server during v6 migration disableLighttpd - # Create target directory /etc/pihole/migration_backup_v6 - # and make it owned by pihole:pihole - mkdir -p "${V6_CONF_MIGRATION_DIR}" - chown pihole:pihole "${V6_CONF_MIGRATION_DIR}" - - # Move all conf files originally created by Pi-hole into this directory - # - 01-pihole.conf - # - 02-pihole-dhcp.conf - # - 04-pihole-static-dhcp.conf - # - 05-pihole-custom-cname.conf - # - 06-rfc6761.conf - - 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 - - # Finally, after everything is in place, we can create the new config file - # /etc/pihole/pihole.toml + # move_old_dnsmasq_ftl_configs() moved everything is in place, + # so 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 + # changed settings via setupVars.conf or the other dnsmasq files moved before # During migration, setupVars.conf is moved to /etc/pihole/migration_backup_v6 str="Migrating Pi-hole configuration to version 6" printf " %b %s..." "${INFO}" "${str}" From 8e706e4a162a85662b15b02a9015754a97b663e2 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Sat, 22 Feb 2025 23:27:05 +0100 Subject: [PATCH 5/5] Assure that Lighttpd conf-enabled symlink is removed `/etc/lighttpd/conf-enabled` usually contains symlinks to the actual files in `/etc/lighttpd/conf-available`, at least `lighty-enable-mod` does exactly this. If `/etc/lighttpd/conf-available/15-pihole-admin.conf` is removed first, `/etc/lighttpd/conf-enabled/15-pihole-admin.conf` hence points to nowhere, which makes the `-f` check return false. The orphaned symlink is hence not removed, if `lighty-disable-mod` is not available. This PR changes the order, to remove the symlink first, and to be failsafe also if it is orphaned already, and the actual config afterwards. Signed-off-by: MichaIng --- automated install/basic-install.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 3680cff3..4a1df70c 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1208,12 +1208,12 @@ remove_old_pihole_lighttpd_configs() { lighty-disable-mod pihole-admin >/dev/null || true fi - if [[ -f "${confavailable}" ]]; then - rm "${confavailable}" + if [[ -f "${confenabled}" || -L "${confenabled}" ]]; then + rm "${confenabled}" fi - if [[ -f "${confenabled}" ]]; then - rm "${confenabled}" + if [[ -f "${confavailable}" ]]; then + rm "${confavailable}" fi }