From: Pieter Lexis Date: Fri, 2 Nov 2018 08:06:55 +0000 (+0100) Subject: Fix up the BIND config files on upgrade X-Git-Tag: dnsdist-1.3.3~4^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F7134%2Fhead;p=thirdparty%2Fpdns.git Fix up the BIND config files on upgrade Fixes #7065 --- diff --git a/builder-support/debian/authoritative/debian-jessie/pdns-backend-bind.postinst b/builder-support/debian/authoritative/debian-jessie/pdns-backend-bind.postinst index ba1173fd47..36610bf8f7 100644 --- a/builder-support/debian/authoritative/debian-jessie/pdns-backend-bind.postinst +++ b/builder-support/debian/authoritative/debian-jessie/pdns-backend-bind.postinst @@ -1,6 +1,16 @@ #!/bin/sh set -e +fix_bind_conf() { + cp /etc/powerdns/pdns.d/bind.conf /etc/powerdns/pdns.d/bind.conf.dpkg-bak + echo "Moving /etc/powerdns/pdns.d/${1} to /etc/powerdns/pdns.d/bind.conf" + mv -f /etc/powerdns/pdns.d/${1} /etc/powerdns/pdns.d/bind.conf + + # Update all references from /etc/powerdns/bindbackend.conf to /etc/powerdns/named.conf + # as we're moving that file. + sed -i 's,/etc/powerdns/bindbackend.conf\(\s*\|$\),/etc/powerdns/named.conf\1,' /etc/powerdns/pdns.d/bind.conf +} + case "$1" in configure) chown pdns:pdns /var/lib/powerdns/zones.slave.d || : @@ -12,6 +22,39 @@ case "$1" in touch $SUPERMASTERCONF chown pdns:pdns $SUPERMASTERCONF fi + + # Older versions had the BIND backend configured in other files. + # If these files were not removed by the pdns-server package postinst, + # that means they were changed by user. Move them into the right places + # so the BIND backend keeps working on an upgrade. + if [ -z "$2" ]; then + # This is a new install. It is possible that it is _part_ of an upgrade from + # an installation that did not have the pdns-backend-bind package but the + # bind backend in the pdns-server package. Let's do the needful and move + # files to keep the bind bindbackend functional. + if [ -e "/etc/powerdns/pdns.d/pdns.simplebind.conf.dpkg-bak" ]; then + # This file was modified by the user, and moved by the installation of pdns-server + cp /etc/powerdns/pdns.d/pdns.simplebind.conf.dpkg-bak /etc/powerdns/pdns.d/pdns.simplebind.conf.dpkg-bak2 + fix_bind_conf pdns.simplebind.conf.dpkg-bak + fi + + if [ -e "/etc/powerdns/pdns.d/pdns.simplebind.conf" ]; then + # The previous package was one from repo.powerdns.com that did not put + # this file under ufc control + cp /etc/powerdns/pdns.d/pdns.simplebind.conf /etc/powerdns/pdns.d/pdns.simplebind.conf.dpkg-bak2 + fix_bind_conf pdns.simplebind.conf + fi + + # Now let's move this out of the way + if [ -e "/etc/powerdns/bindbackend.conf" ]; then + # This file was modified by the user (if not, it was removed by the installation + # of pdns-server), so make sure this file is not lost + cp /etc/powerdns/bindbackend.conf /etc/powerdns/bindbackend.conf.dpkg-bak + cp /etc/powerdns/named.conf /etc/powerdns/named.conf.dpkg-bak + echo "Moving /etc/powerdns/bindbackend.conf to /etc/powerdns/named.conf" + mv -f /etc/powerdns/bindbackend.conf /etc/powerdns/named.conf + fi + fi ;; abort-upgrade|abort-remove|abort-deconfigure) diff --git a/builder-support/debian/authoritative/debian-stretch/pdns-backend-bind.postinst b/builder-support/debian/authoritative/debian-stretch/pdns-backend-bind.postinst index ba1173fd47..36610bf8f7 100644 --- a/builder-support/debian/authoritative/debian-stretch/pdns-backend-bind.postinst +++ b/builder-support/debian/authoritative/debian-stretch/pdns-backend-bind.postinst @@ -1,6 +1,16 @@ #!/bin/sh set -e +fix_bind_conf() { + cp /etc/powerdns/pdns.d/bind.conf /etc/powerdns/pdns.d/bind.conf.dpkg-bak + echo "Moving /etc/powerdns/pdns.d/${1} to /etc/powerdns/pdns.d/bind.conf" + mv -f /etc/powerdns/pdns.d/${1} /etc/powerdns/pdns.d/bind.conf + + # Update all references from /etc/powerdns/bindbackend.conf to /etc/powerdns/named.conf + # as we're moving that file. + sed -i 's,/etc/powerdns/bindbackend.conf\(\s*\|$\),/etc/powerdns/named.conf\1,' /etc/powerdns/pdns.d/bind.conf +} + case "$1" in configure) chown pdns:pdns /var/lib/powerdns/zones.slave.d || : @@ -12,6 +22,39 @@ case "$1" in touch $SUPERMASTERCONF chown pdns:pdns $SUPERMASTERCONF fi + + # Older versions had the BIND backend configured in other files. + # If these files were not removed by the pdns-server package postinst, + # that means they were changed by user. Move them into the right places + # so the BIND backend keeps working on an upgrade. + if [ -z "$2" ]; then + # This is a new install. It is possible that it is _part_ of an upgrade from + # an installation that did not have the pdns-backend-bind package but the + # bind backend in the pdns-server package. Let's do the needful and move + # files to keep the bind bindbackend functional. + if [ -e "/etc/powerdns/pdns.d/pdns.simplebind.conf.dpkg-bak" ]; then + # This file was modified by the user, and moved by the installation of pdns-server + cp /etc/powerdns/pdns.d/pdns.simplebind.conf.dpkg-bak /etc/powerdns/pdns.d/pdns.simplebind.conf.dpkg-bak2 + fix_bind_conf pdns.simplebind.conf.dpkg-bak + fi + + if [ -e "/etc/powerdns/pdns.d/pdns.simplebind.conf" ]; then + # The previous package was one from repo.powerdns.com that did not put + # this file under ufc control + cp /etc/powerdns/pdns.d/pdns.simplebind.conf /etc/powerdns/pdns.d/pdns.simplebind.conf.dpkg-bak2 + fix_bind_conf pdns.simplebind.conf + fi + + # Now let's move this out of the way + if [ -e "/etc/powerdns/bindbackend.conf" ]; then + # This file was modified by the user (if not, it was removed by the installation + # of pdns-server), so make sure this file is not lost + cp /etc/powerdns/bindbackend.conf /etc/powerdns/bindbackend.conf.dpkg-bak + cp /etc/powerdns/named.conf /etc/powerdns/named.conf.dpkg-bak + echo "Moving /etc/powerdns/bindbackend.conf to /etc/powerdns/named.conf" + mv -f /etc/powerdns/bindbackend.conf /etc/powerdns/named.conf + fi + fi ;; abort-upgrade|abort-remove|abort-deconfigure) diff --git a/builder-support/debian/authoritative/ubuntu-trusty/pdns-backend-bind.postinst b/builder-support/debian/authoritative/ubuntu-trusty/pdns-backend-bind.postinst index ba1173fd47..36610bf8f7 100644 --- a/builder-support/debian/authoritative/ubuntu-trusty/pdns-backend-bind.postinst +++ b/builder-support/debian/authoritative/ubuntu-trusty/pdns-backend-bind.postinst @@ -1,6 +1,16 @@ #!/bin/sh set -e +fix_bind_conf() { + cp /etc/powerdns/pdns.d/bind.conf /etc/powerdns/pdns.d/bind.conf.dpkg-bak + echo "Moving /etc/powerdns/pdns.d/${1} to /etc/powerdns/pdns.d/bind.conf" + mv -f /etc/powerdns/pdns.d/${1} /etc/powerdns/pdns.d/bind.conf + + # Update all references from /etc/powerdns/bindbackend.conf to /etc/powerdns/named.conf + # as we're moving that file. + sed -i 's,/etc/powerdns/bindbackend.conf\(\s*\|$\),/etc/powerdns/named.conf\1,' /etc/powerdns/pdns.d/bind.conf +} + case "$1" in configure) chown pdns:pdns /var/lib/powerdns/zones.slave.d || : @@ -12,6 +22,39 @@ case "$1" in touch $SUPERMASTERCONF chown pdns:pdns $SUPERMASTERCONF fi + + # Older versions had the BIND backend configured in other files. + # If these files were not removed by the pdns-server package postinst, + # that means they were changed by user. Move them into the right places + # so the BIND backend keeps working on an upgrade. + if [ -z "$2" ]; then + # This is a new install. It is possible that it is _part_ of an upgrade from + # an installation that did not have the pdns-backend-bind package but the + # bind backend in the pdns-server package. Let's do the needful and move + # files to keep the bind bindbackend functional. + if [ -e "/etc/powerdns/pdns.d/pdns.simplebind.conf.dpkg-bak" ]; then + # This file was modified by the user, and moved by the installation of pdns-server + cp /etc/powerdns/pdns.d/pdns.simplebind.conf.dpkg-bak /etc/powerdns/pdns.d/pdns.simplebind.conf.dpkg-bak2 + fix_bind_conf pdns.simplebind.conf.dpkg-bak + fi + + if [ -e "/etc/powerdns/pdns.d/pdns.simplebind.conf" ]; then + # The previous package was one from repo.powerdns.com that did not put + # this file under ufc control + cp /etc/powerdns/pdns.d/pdns.simplebind.conf /etc/powerdns/pdns.d/pdns.simplebind.conf.dpkg-bak2 + fix_bind_conf pdns.simplebind.conf + fi + + # Now let's move this out of the way + if [ -e "/etc/powerdns/bindbackend.conf" ]; then + # This file was modified by the user (if not, it was removed by the installation + # of pdns-server), so make sure this file is not lost + cp /etc/powerdns/bindbackend.conf /etc/powerdns/bindbackend.conf.dpkg-bak + cp /etc/powerdns/named.conf /etc/powerdns/named.conf.dpkg-bak + echo "Moving /etc/powerdns/bindbackend.conf to /etc/powerdns/named.conf" + mv -f /etc/powerdns/bindbackend.conf /etc/powerdns/named.conf + fi + fi ;; abort-upgrade|abort-remove|abort-deconfigure)