Avoid trying to create the symlink if there's a dangling symlink already

'test -e' says 'no' for dangling symlinks.

Let's also ignore the error if this fails. We shouldn't fail the
transaction.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2022-02-24 20:25:55 +01:00
parent 2ea657e54b
commit 9c9b28cd91
1 changed files with 3 additions and 3 deletions

View File

@ -959,11 +959,11 @@ if systemctl -q is-enabled systemd-resolved.service &>/dev/null &&
! systemd-analyze cat-config systemd/resolved.conf 2>/dev/null |
grep -iqE '^DNSStubListener\s*=\s*(no?|false|0|off)\s*$'; then
if ! test -e /etc/resolv.conf; then
ln -sv ../run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
if ! test -e /etc/resolv.conf && ! test -L /etc/resolv.conf; then
ln -sv ../run/systemd/resolve/stub-resolv.conf /etc/resolv.conf || :
elif test -d /run/systemd/system/ &&
! mountpoint /etc/resolv.conf &>/dev/null; then
ln -fsv ../run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
ln -fsv ../run/systemd/resolve/stub-resolv.conf /etc/resolv.conf || :
fi
fi