I am attempting to setup CNAMEs in Avahi in order to broadcast multiple hostnames. I've found a variety of examples online that all work but they all require long lived processes:
https://github.com/Dalee/avahi-cname-aliases/blob/master/avahi_cname_aliases/init.py#L83
# run and stay foreground
def run(self):
self.set_handlers()
self.load_aliases()
self.publish_aliases()
# keep aliases published
while self.running:
time.sleep(TTL)
https://github.com/george-hawkins/avahi-aliases-notes/blob/master/avahi-alias#L48
for name in sys.argv[1:]:
publish_cname(name)
try:
# Just loop forever
while 1: time.sleep(60)
except KeyboardInterrupt:
print("Exiting")
https://public.msli.com/lcs/jaf/publish_cnames.c
/** cnames should be a NULL-terminated array of alias hostnames for this host.
* Example invocation: const char * cnames = {"foo.local", "bar.local", NULL}; PublishAvahiCNames(cnames);
* Note that this function normally does not ever return!
*/
void PublishAvahiCNames(const char ** cnames)
I've confirmed that if the process that sets up the CNAME ends then the CNAME disappears but I can't find any documentation on avahi or dbus that indicates why these tools need to live forever. My use of dbus-monitor
hasn't shown anything obvious that the scripts are doing to keep the CNAMEs alive.
Does anyone know what these scripts are doing to keep the published CNAMEs active in avahi?