netcup: dns fixes

This commit is contained in:
Girish Ramakrishnan
2024-05-04 17:36:26 +02:00
parent 1728756dc4
commit 6681f2e5c8
3 changed files with 27 additions and 6 deletions

View File

@@ -25,10 +25,17 @@ apt-get -o Dpkg::Options::="--force-confdef" update -y
apt-get -o Dpkg::Options::="--force-confdef" upgrade -y
apt-mark unhold grub* >/dev/null
# workaround netcup setting immutable bit. can be removed in 8.0
if lsattr -l /etc/resolv.conf 2>/dev/null | grep -q Immutable; then
echo "==> Fixing up /etc/resolv.conf"
chattr -i /etc/resolv.conf
vendor=$(cat /sys/devices/virtual/dmi/id/sys_vendor || true)
if [[ "${vendor}" == "netcup" && ! -L /etc/resolv.conf ]]; then
echo "==> Fix netcup DNS setup"
nameservers=$(sed -ne 's/nameserver \(.*\)/"\1"/p' /etc/resolv.conf | paste -sd "," -) # json array
if lsattr -l /etc/resolv.conf 2>/dev/null | grep -q Immutable; then
chattr -i /etc/resolv.conf # this code is also in cloudron-setup. that code can be removed much after 8.0
fi
ln -frs /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
netplan set --origin-hint 50-cloud-init "ethernets.eth0.nameservers.addresses=[${nameservers}]"
netplan apply # generates /run/systemd/resolve/resolv.conf
systemctl restart systemd-resolved
fi
echo "==> Installing required packages"