Creating an OS X Startup Item For BIND

This information is really geared for pre-Tiger versions of OS X. In OS X 10.4 (Tiger), the BIND daemon is controlled by launchd and is pre-configured (although disabled). BIND Startup in Mac OS X 10.4 (Tiger) has more detailed information. Although outdated, this article still includes useful information.

Although OS X ~~10.4 (Tiger)~~ comes with BIND 9 pre-installed, it doesn't have a Startup Item. Without a Startup Item, it can't start automatically when the system boots.

OS X Startup Items can live in one of two directories: /System/Library/StartupItems/ or /Library/StartupItems/. Personally, I prefer /System/Library/StartupItems/ since most of the Startup Items are kept there. (It's worth noting that MySQL puts it's Startup Item in /Library/StartupItems/, but that's the only thing there on my PowerBook G4.) In the next sequence of steps, we'll create our Startup Item directory, executable shell script, and properties list from the command line. As usual, the '\$' represents the shell prompt and shouldn't be typed.

$ cd /System/Library/StartupItems
$ sudo mkdir BIND
$ sudo touch BIND
$ sudo chmod 755 BIND
$ sudo touch StartupParameters.plist

That may seem a bit quick, but all we did is 1) create our Startup Item directory, 2) created our shell script file, 3) made the shell script executable, and 4) created our properties list file.

Next, we need to put some meat in the executable shell script. You can use your favorite text editor for this. Personally, I use Vim, but I know that some folks really enjoy TextMate. Add the following text to the file we created called 'BIND'.


. /etc/rc.common

if [ "${DNSSERVER}" = "-YES-" ]; then
  ConsoleMessage "Starting BIND DNS Server"

Finally, we need to flesh out our properties list file ('StartupParameters.plist'). Again you can use any text editor (ahem, Vim) or the PropertyListEditor that comes with the OS X Developer CD.

  Description = "Local Caching DNS Server";
  Provides = ("DNS Server");
  OrderPreference = "None";
  Messages =
  start = "Starting BIND DNS Server";
  stop = "Stopping BIND DNS Server";

I've made these two items available as a download if you are having trouble.


Related Reading:

My Bookshelf

Reading Now

Other Stuff