rendezvous/zeroconf in UNIX

I took another look at advertising services in Rendezvous and found that someone had written an init script for UNIX/Linux systems.

It launches the mDNSResponder service and mDNSPublish, which is OK if you only have one service. I decided to break them apart since I may have more than one. So below the fold, you’ll find an init script for mDNSResponder. As I figure out how to, I’ll work up one that reads some kind of config file and launches multiple services (sounds like a trivial think to do with awk, actually).

#!/bin/sh

# stolen from 'greenstripe'(a/k/a Manfred Heindl) on the MacOSXhints.com website
# this is only part of what I 'borrowed.'

# mDNSResponder
MDNS_RESPONDER_EXEC='/usr/local/bin/mDNSResponder'
MDNS_RESPONDER_CMDLINE='-i xl1' # change this to your interface
MDNS_RESPONDER_LOGFILE='/var/log/mDNSResponder.log'
MDNS_RESPONDER_PIDFILE='/var/run/mDNSResponder.pid'

case "$1" in
start)
if [ -x "${MDNS_RESPONDER_EXEC}" ]; then
${MDNS_RESPONDER_EXEC} ${MDNS_RESPONDER_CMDLINE} >> ${MDNS_RESPONDER_LOGFILE} 2>&1 && echo -n ' mDNS Responder'

fi
;;
stop)
killall mDNSResponder 2>/dev/null
if [ $? -ne 0 ] ; then
echo 'mDNSResponder not started'
fi
;;
restart)
$0 stop
sleep 2
$0 start
;;
*)
echo ""
echo "Usage: `basename $0` { start | stop | restart }"
echo ""
exit 64
;;
esac