Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate dnsmasq config files #5479

Merged
merged 5 commits into from
May 12, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 34 additions & 0 deletions automated install/basic-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ QUERY_LOGGING=true
WEBPORT=8080
PRIVACY_LEVEL=0

# Where old configs go to if a v6 migration is performed
V6_CONF_MIGRATION_DIR="/etc/pihole/migration_backup_v6"

if [ -z "${USER}" ]; then
USER="$(id -un)"
fi
Expand Down Expand Up @@ -2070,6 +2073,34 @@ copy_to_install_log() {
chown pihole:pihole "${installLogLoc}"
}

migrate_dnsmasq_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
# 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 /etc/pihole/pihole.toml ]]; then
return 0
fi

# 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_MIGRATION_DIR}/" 2>/dev/null || true
DL6ER marked this conversation as resolved.
Show resolved Hide resolved
}

main() {
######## FIRST CHECK ########
# Must be root to install
Expand Down Expand Up @@ -2219,6 +2250,9 @@ main() {
pihole -a -p "${pw}"
fi

# Migrate existing install to v6.0
migrate_dnsmasq_configs

# Check for and disable systemd-resolved-DNSStubListener before reloading resolved
# DNSStubListener needs to remain in place for installer to download needed files,
# so this change needs to be made after installation is complete,
Expand Down