We’e got everything compiled and configured to its time to try to start everything up and to test if it is working properly. These scripts will also have everything start-up automatically after a reboot. Apache and MySQL have been configured to start after a reboot now it’s time to take care of the mailserver components.
Courier Auth daemon
Create a directory ‘CourierAuth‘ in the directory ‘/Library/StartupItems‘.
sudo mkdir CourierAuth
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 ‘CourierAuth‘ and this is what its content should look like:
# Courier Auth startup item
# http://diymacserver.com
#
. /etc/rc.common
StartService ()
{
if [ "${CAUTHSERVER:=-NO-}" = "-YES-" ]; then
echo “Starting Courier Auth server”
/usr/local/sbin/authdaemond start
fi
}
StopService ()
{
echo “Stopping Courier Auth server”
/usr/local/sbin/authdaemond stop
}
RestartService ()
{
if [ "${CAUTHSERVER:=-NO-}" = "-YES-" ]; then
echo “Restarting Courier Auth server”
StopService
StartService
else
StopService
fi
}
RunService “$1″
Set the executable bit on the script using:
The other file to create in this directory is ‘StartupParameters.plist‘, have it look like:
Description = "Courier Auth server";
Provides = ("Authentication Server");
Uses = ("Disks", "NFS");
}
The last thing for Courier Auth is to add the following line to the ‘/etc/hostconfig‘ file:
Courier IMAP daemon
The IMAP daemon is configured the same as the authentication daemon, the difference is in the details.
Create a directory ‘CourierIMAP‘ in the directory ‘/Library/StartupItems‘
sudo mkdir CourierIMAP
Next you need to create the file ‘/Library/StartupItems/CourierIMAP/CourierIMAP‘ and have it look like:
# Courier IMAP startup item
# http://diymacserver.com
#
. /etc/rc.common
StartService ()
{
if [ "${IMAPSERVER:=-NO-}" = "-YES-" ]; then
echo “Starting Courier IMAP server”
/usr/local/libexec/imapd.rc start
fi
}
StopService ()
{
echo “Stopping Courier IMAP server”
/usr/local/libexec/imapd.rc stop
}
RestartService ()
{
if [ "${IMAPSERVER:=-NO-}" = "-YES-" ]; then
echo “Restarting Courier IMAP server”
StopService
StartService
else
StopService
fi
}
RunService “$1″
Set the executable bit on the script using:
The other file to create in this directory is ‘StartupParameters.plist‘, have it look like:
{
Description = "Courier IMAP server";
Provides = ("IMAP Server");
Uses = ("Disks", "NFS");
}
The last thing for Courier IMAP is to add the following line to the ‘/etc/hostconfig‘ file:
Postfix
The Postfix daemon is configured the same as the authentication and IMAP daemon, the difference is in the details.
Create a directory ‘Postfix‘ in the directory ‘/Library/StartupItems‘.
sudo mkdir Postfix
Next you need to create the file ‘/LibraryStartupItems/Postfix/Postfix‘ and have it look like:
# Postifx startup item
# http://diymacserver.com
#
. /etc/rc.common
StartService ()
{
if [ "${MAILSERVER:=-NO-}" = "-YES-" ]; then
echo “Starting Postfix mail server”
postfix start
fi
}
StopService ()
{
echo “Stopping Postfix mail server”
postfix stop
}
RestartService ()
{
if [ "${MAILSERVER:=-NO-}" = "-YES-" ]; then
echo “Restarting Postfix mail server”
postfix reload
else
StopService
fi
}
RunService “$1″
The other file to create in this directory is ‘StartupParameters.plist‘, have it look like:
{
Description = "Postfix Mail server";
Provides = ("Mail Server");
Uses = ("Disks", "NFS");
}
Set the executable bit on the script using:
The last thing for Postfix is to add the following line to the ‘/etc/hostconfig‘ file:
Courier POP3 daemon
The POP3 daemon is optional and you can add this as well but it isn’t required. If you are going to use it I hope you also changed the pop3d configuration file.
Create a directory ‘CourierPOP3‘ in the directory ‘/Library/StartupItems‘
sudo mkdir CourierPOP3
Next you need to create the file ‘/Library/StartupItems/CourierPOP3/CourierPOP3‘ and have it look like:
# Courier POP3 startup item
# http://diymacserver.com
#
. /etc/rc.common
StartService ()
{
if [ "${POP3SERVER:=-NO-}" = "-YES-" ]; then
echo “Starting Courier POP3 server”
/usr/local/libexec/pop3d.rc start
fi
}
StopService ()
{
echo “Stopping Courier POP3 server”
/usr/local/libexec/pop3d.rc stop
}
RestartService ()
{
if [ "${POP3SERVER:=-NO-}" = "-YES-" ]; then
echo “Restarting Courier POP3 server”
StopService
StartService
else
StopService
fi
}
RunService “$1″
The other file to create in this directory is ‘StartupParameters.plist‘, have it look like:
{
Description = "Courier POP3 server";
Provides = ("POP3 Server");
Uses = ("Disks", "NFS");
}
Set the executable bit on the script using:
The last thing for Courier POP3 is to add the following line to the ‘/etc/hostconfig‘ file:
Now you can start all programs by typing the following commands:
sudo /Library/StartupItems/CourierIMAP/CourierIMAP start
sudo /Library/StartupItems/Postfix/Postfix start
and if you require pop3 access:
If you look at the logfile ‘/var/log/mail.log‘ you could see if all programs started succesfully.
Next step: Installing Postfix admin



11:51 pm
Me again.
Am getting ‘unknown argument: “start “‘ when trying to start up any of the services.
Have copied and pasted them as above.
After getting past the authdaemon problem, I really though this time I’d be able to do it it, but alas, shot down at the last hurdle…