From 6824ce0d0f523c6f95bc7790f4eb0a4f5ba472dd Mon Sep 17 00:00:00 2001 From: Jarek <65668659+jardahrazdera@users.noreply.github.com> Date: Tue, 9 Sep 2025 21:01:22 +0200 Subject: [PATCH] Enable full mDNS resolution for .local domains (#1021) * Enable full mDNS resolution for .local domains * Add migration to enable mDNS resolution for existing users --- install/config/hardware/printer.sh | 3 +++ migrations/1757361128.sh | 7 +++++++ 2 files changed, 10 insertions(+) create mode 100644 migrations/1757361128.sh diff --git a/install/config/hardware/printer.sh b/install/config/hardware/printer.sh index 5a752b2..b737b49 100755 --- a/install/config/hardware/printer.sh +++ b/install/config/hardware/printer.sh @@ -7,6 +7,9 @@ sudo mkdir -p /etc/systemd/resolved.conf.d echo -e "[Resolve]\nMulticastDNS=no" | sudo tee /etc/systemd/resolved.conf.d/10-disable-multicast.conf chrootable_systemctl_enable avahi-daemon.service +# Enable mDNS resolution for .local domains +sudo sed -i 's/^hosts:.*/hosts: mymachines mdns_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] files myhostname dns/' /etc/nsswitch.conf + # Enable automatically adding remote printers if ! grep -q '^CreateRemotePrinters Yes' /etc/cups/cups-browsed.conf; then echo 'CreateRemotePrinters Yes' | sudo tee -a /etc/cups/cups-browsed.conf diff --git a/migrations/1757361128.sh b/migrations/1757361128.sh new file mode 100644 index 0000000..b6c8413 --- /dev/null +++ b/migrations/1757361128.sh @@ -0,0 +1,7 @@ +echo "Enable mDNS resolution for existing Avahi installations" + +if systemctl is-enabled avahi-daemon.service >/dev/null 2>&1; then + if ! grep -q "mdns_minimal" /etc/nsswitch.conf; then + sudo sed -i 's/^hosts:.*/hosts: mymachines mdns_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] files myhostname dns/' /etc/nsswitch.conf + fi +fi \ No newline at end of file