Add support to notify avahi-daemon and mdnsd of resolv.conf changes
authorRoy Marples <roy@marples.name>
Wed, 22 Jul 2020 12:30:55 +0000 (13:30 +0100)
committerRoy Marples <roy@marples.name>
Wed, 22 Jul 2020 12:30:55 +0000 (13:30 +0100)
.gitignore
Makefile
avahi-daemon.in [new file with mode: 0644]
mdnsd.in [new file with mode: 0644]

index 1379bd0604efc74ea8a932d8523dc02c20f2af88..ab2bd4fe7b7a18cbbb33d8f9bbfbcdafba673270 100644 (file)
@@ -10,3 +10,6 @@ named
 pdnsd
 pdns_recursor
 unbound
+
+avahi-daemon
+mdnsd
index 6cfa6e4ea07255424f9e42bcce4dc69b3175d2f2..73fbb9a51048084c0dde2d490e8bfdddcbb7c356 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -20,9 +20,10 @@ BINMODE?=    0755
 DOCMODE?=      0644
 MANMODE?=      0444
 
-RESOLVCONF=    resolvconf resolvconf.8 resolvconf.conf.5
-SUBSCRIBERS=   libc dnsmasq named pdnsd pdns_recursor unbound
-TARGET=                ${RESOLVCONF} ${SUBSCRIBERS}
+RESOLVCONF=            resolvconf resolvconf.8 resolvconf.conf.5
+SUBSCRIBERS=           libc dnsmasq named pdnsd pdns_recursor unbound
+LIBC_SUBSCRIBERS=      avahi-daemon mdnsd
+TARGET=                ${RESOLVCONF} ${SUBSCRIBERS} ${LIBC_SUBSCRIBERS}
 SRCS=          ${TARGET:C,$,.in,} # pmake
 SRCS:=         ${TARGET:=.in} # gmake
 
@@ -71,6 +72,9 @@ proginstall: ${TARGET}
        ${INSTALL} -m ${DOCMODE} resolvconf.conf ${DESTDIR}${SYSCONFDIR}
        ${INSTALL} -d ${DESTDIR}${LIBEXECDIR}
        ${INSTALL} -m ${DOCMODE} ${SUBSCRIBERS} ${DESTDIR}${LIBEXECDIR}
+       ${INSTALL} -d ${DESTDIR}${LIBEXECDIR}/libc.d
+       ${INSTALL} -m ${DOCMODE} ${LIBC_SUBSCRIBERS} \
+               ${DESTDIR}${LIBEXECDIR}/libc.d
 
 maninstall:
        ${INSTALL} -d ${DESTDIR}${MANDIR}/man8
diff --git a/avahi-daemon.in b/avahi-daemon.in
new file mode 100644 (file)
index 0000000..529e4ae
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+# Copyright (c) 2007-2020 Roy Marples
+# All rights reserved
+
+# avahi-daemon notifier for resolvconf libc subscriber
+
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+#       copyright notice, this list of conditions and the following
+#       disclaimer in the documentation and/or other materials provided
+#       with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+: ${avahi_daemon_pidfile:=/var/run/avahi-daemon/pid}
+if [ -s "$avahi_daemon_pidfile" ]; then
+       kill -HUP $(cat "$avahi_daemon_pidfile")
+fi
diff --git a/mdnsd.in b/mdnsd.in
new file mode 100644 (file)
index 0000000..399cf56
--- /dev/null
+++ b/mdnsd.in
@@ -0,0 +1,32 @@
+#!/bin/sh
+# Copyright (c) 2007-2020 Roy Marples
+# All rights reserved
+
+# mdnsd notifier for resolvconf libc subscriber
+
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+#       copyright notice, this list of conditions and the following
+#       disclaimer in the documentation and/or other materials provided
+#       with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+: ${mdnsd_pidfile:=/var/run/mdnsd/mdnsd.pid}
+if [ -s "$mdnsd_pidfile" ]; then
+       kill -HUP $(cat "$mdnsd_pidfile")
+fi