A script to restart NetInfo parent databases

Oct 01, '02 08:37:58AM

Contributed by: Anonymous

After making changes to NetInfo parent databases accessed by client computers, it is customary to restart your server. A more elegant way is to just restart the netinfod processes. This is done by sending a Hang Up signal to the nibindd process, which also restarts any and all netinfod processes running. Note that you must have a parent NetInfo database running to have a nibindd process, so this hint usually doesn't apply to Mac OS X non-server computers.

If you use the following script in a .command file so you can run it by double-clicking the document in the Finder, don't use the string 'nibind' anywhere in the file name as it will generate some error messages. I leave the reason as an exercise for the students.

#!/bin/sh
#
# A shell script to restart nibindd
#

# Get the PID of nibindd
pid=`ps -ax | grep nibind | grep -v grep | awk '{print $1}'`
echo "Current PID of nibindd is" $pid

# Authenticate and restart the process
echo "Please authenticate to restart nibindd..."
sudo kill -HUP $pid

# Wait for the old process to die
sleep 1

# Display the new PID to confirm that it worked
pid=`ps -ax | grep nibind | grep -v grep | awk '{print $1}'`
echo "New PID of nibindd is" $pid
Remember to make the script executable and place it somewhere on your path.

Comments (1)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20021001053758467