Now you’ve got SQLGrey running but you will want to have it start after a reboot as well, therefore the next job at hand is to create the startup scripts for a Leopard and Tiger installation.

Leopard
Create a file called ‘com.diymacserver.sqlgrey.plist‘ in the directory ‘/System/Library/LaunchDaemons/‘. The content of the file should look like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>com.diymacserver.sqlgrey</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/sbin/sqlgrey</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>KeepAlive</key>
  <true/>
</dict>
</plist>

To load and activate the .plist file and to make sure that it is started after a reboot you’ll need to load the plist file by using the command:

sudo launchctl load /System/Library/LaunchDaemons/com.diymacserver.sqlgrey.plist

You can see if it loaded correctly by using the command:

sudo launchctl list

This will show you all the active plist files.

You can see if everything went correctly by trying to start it using:

sudo launchctl start com.diymacserver.sqlgrey

Tiger
Create a directory ‘SQLGrey‘ in the directory /Library/StartupItems‘.

cd /Library/StartupItems
sudo mkdir SQLGrey

Use your favourite editor to create the following files into your newly created directory. Please make sure you create them as root using the sudo command.

The first file is called ‘SQLGrey‘ and this is what its content should look like:

#!/bin/sh
# SQLGrey startup item
# http://diymacserver.com
#
. /etc/rc.common
StartService ()
{
  echo “Starting SQLGrey daemon”
  /usr/sbin/sqlgrey -d
}
 
StopService ()
{
  echo “Stopping SQLGrey daemon”
  /usr/sbin/sqlgrey -k
}
 
RestartService ()
{
  echo “Restarting SQLGrey daemon”
  StopService
  StartService
}
 
RunService “$1″

Set the executable bit on the script using:

sudo chmod +x /Library/StartupItems/SQLGrey/SQLGrey

The other file to create in this directory is ‘StartupParameters.plist‘, have it look like:
{
  Description = “SQLGrey daemon”;
  Provides = (“AGreylisting daemon”);
  Uses = (“Disks”, “NFS”);
}

This should do it for you, you can now safely reboot and all will be fine when the mini has started again.