restart-lookupd   [plain text]


#!/bin/sh
#
# restart-lookupd
#

PIDFILE="/var/run/lookupd.pid"

#
# Check for a PID file. There's something wrong if
# the file is missing.
#
if [ ! -f ${PIDFILE} ]; then
	#
	# "lookupd" PID file not found, exiting
	#
	logger -i -p daemon.notice -t restart-lookupd "${PIDFILE} missing"
	exit 0
fi
oPID=`/bin/cat ${PIDFILE}`

#
# Send a SIGHUP to the "lookupd" process.
#
kill -HUP ${oPID}
status=$?
if [ $status -ne 0 ]; then
	logger -i -p daemon.notice -t restart-lookupd "Could not SIGHUP lookupd, pid=${oPID}, status=${status}"
	exit 0
fi

#
# Touch the cache key to cause a notification
#
scutil << __END_OF_SCUTIL_COMMAND > /dev/null 2>&1
open
touch File:/var/run/lookupd.pid
close
quit
__END_OF_SCUTIL_COMMAND

exit 0