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>
This commit is contained in:
Petr Menšík 2021-11-06 19:20:44 +01:00 committed by zbyszek
parent 9309bd3038
commit 27cc5e08c2

View File

@ -920,6 +920,14 @@ if [ $1 -eq 0 ] ; then
systemctl disable --quiet \ systemctl disable --quiet \
systemd-resolved.service \ systemd-resolved.service \
>/dev/null || : >/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 fi
%post resolved %post resolved