#!/bin/sh
NIBINDD_PIDFILE="/var/run/nibindd.pid"
NILOCAL_PIDFILE="/var/run/netinfo_local.pid"
if [ -f ${NIBINDD_PIDFILE} ]; then
oPID=`cat ${NIBINDD_PIDFILE}`
kill -HUP ${oPID}
status=$?
if [ $status -ne 0 ]; then
logger -i -p daemon.notice -t restart-NetInfo "Could not SIGHUP nibindd, pid=${oPID}, status=${status}"
exit 0
fi
CHECK=1
LIMIT=60
while [ 1 ]
do
if [ -f ${NIBINDD_PIDFILE} ]; then
nPID=`cat ${NIBINDD_PIDFILE}`
if [ "X${oPID}" != "X${nPID}" ]; then
break
fi
fi
CHECK=`expr ${CHECK} + 1`
if [ ${CHECK} -le ${LIMIT} ]; then
sleep 1
else
logger -i -p daemon.notice -t restart-NetInfo "nibindd restart failed"
exit 0
fi
done
while [ 1 ]
do
niutil -read -T 1 -t 127.0.0.1/local / > /dev/null 2>&1
if [ $? -eq 0 ]; then
break
fi
CHECK=`expr ${CHECK} + 1`
if [ ${CHECK} -le ${LIMIT} ]; then
sleep 1
else
logger -i -p daemon.notice -t restart-NetInfo "\"netinfod local\" not starting (fast enough)"
exit 0
fi
done
elif [ -f ${NILOCAL_PIDFILE} ]; then
PID=`cat ${NILOCAL_PIDFILE}`
kill -HUP ${PID}
status=$?
if [ $status -ne 0 ]; then
logger -i -p daemon.notice -t restart-NetInfo "Could not SIGHUP netinfod local, pid=${PID}, status=${status}"
exit 0
fi
else
logger -i -p daemon.notice -t restart-NetInfo "NetInfo daemons not running"
exit 0
fi
scutil << __END_OF_SCUTIL_COMMAND > /dev/null 2>&1
open
touch File:/var/run/nibindd.pid
close
quit
__END_OF_SCUTIL_COMMAND
exit 0