Switch to NM resolver on systemd-resolved uninstall

If /etc/resolv.conf pointed to systemd-resolved stub configuration, it
is obvious it would stop working. Compensate it by deleting the link, it
would be created again on installation. Try to pass ownership to NM,
which also provides similar file. Keep it missing otherwise, might be
created by unknown tool on reboot.

Signed-off-by: Petr Menšík <pemensik@redhat.com>
(cherry picked from commit 27cc5e08c2)
This commit is contained in:
Petr Menšík 2021-11-06 19:20:44 +01:00 committed by Zbigniew Jędrzejewski-Szmek
parent 0892c0e617
commit df4de9640e
1 changed files with 8 additions and 0 deletions

View File

@ -918,6 +918,14 @@ if [ $1 -eq 0 ] ; then
systemctl disable --quiet \
systemd-resolved.service \
>/dev/null || :
if [ -L %{_sysconfdir}/resolv.conf ] && \
realpath %{_sysconfdir}/resolv.conf | grep ^/run/systemd/resolve/; then
rm -f %{_sysconfdir}/resolv.conf # no longer useful
# if network manager is enabled, move to it instead
[ -f /run/NetworkManager/resolv.conf ] && \
systemctl -q is-enabled NetworkManager.service &>/dev/null && \
ln -fsv ../run/NetworkManager/resolv.conf %{_sysconfdir}/resolv.conf
fi
fi
%post resolved