freebsdrocks.net was started originally as nospam.mine.nu.
Lets start with installing the port and configuring the options for it:
# echo "WITHOUT_X11=yes" >> /etc/make.conf
# echo "NO_X=yes" >> /etc/make.conf
# cd /usr/ports/lang/expect
# make install clean
# cd /usr/ports/mail/courier-imap
# make install clean
When you run make install clean on courier-imapd, be sure to make sure the following boxes are checked:
IPV6
AUTH_VCHKPW
Once that is done, We will want to install courierpassd:
# cd /usr/ports/security/courierpassd
# make install clean
Lets run mkdhparams before we do anything else.
# /usr/local/share/courier-imap/mkdhparams
Now we will want to delete the startup file in the /usr/local/etc/rc.d folder:
# rm /usr/local/etc/rc.d/courier-authdaemond
Next we need to set up the daemontools directory structure for the courierpasswd service. I now use /var/qmail/svc as the physical location for my service directories, you can use whatever you like except that it cannot be /service itself. The examples below will assume you are using /var/service like I did- if you are using something different, adjust the paths where appropriate.
# cd /var/qmail/svc
# mkdir /var/log/courier-passwd
# mkdir -m 1755 courier-passwd
# cd courier-passwd
# cp /root/qmail/service-courierpassd-run run
# chmod 755 run
# mkdir -m 755 log
# cd log
# cp /root/qmail/service-any-log-run run
# chmod 755 run
# vi run
In the run file change the second-to-last line to match the following:
multilog t n1024 s1048576 /var/log/courier-passwd \
The last step, of course, is to start the service running:
# ln -s /var/qmail/svc/courier-passwd /service/courier-passwd
Wait about 5 seconds and then run the following command:
# svstat /service/courier-passwd/ /service/courier-passwd/log/
Now we want to setup a few files:
# cd /usr/local/etc/courier-imap
# cp imapd.cnf.dist imapd.cnf
# cp imapd-ssl.dist imapd-ssl
Now we need to make the imap cert:
# /usr/local/share/courier-imap/mkimapdcert
Now edit the following file:
# vi /usr/local/etc/authlib/authdaemonrc
And change the following section:
authmodulelist="authvchkpw"
Now to setup the courier-authdaemond service:
# cd /var/qmail/svc
# mkdir /var/log/courier-authdaemond
# mkdir -m 1755 courier-authdaemond
# cd courier-authdaemond
# cp /root/qmail/courier-authdaemond-run run
# chmod 755 run
# mkdir -m 755 log
# cd log
# cp /root/qmail/service-any-log-run run
# chmod 755 run
# vi run
In the run file change the second-to-last line to match the following:
multilog t n1024 s1048576 /var/log/courier-authdaemond \
and finally link authdaemond to /service:
# ln -s /var/qmail/svc/courier-authdaemond /service/courier-authdaemond
Wait about 5 seconds and then run the following command:
# svstat /service/courier-authdaemond/ /service/courier-authdaemond/log/
Now, before we start to work on getting courier running via daemontools rather than using the scripts, we are going to want to delete the scripts in /usr/local/etc/rc.d:
# rm /usr/local/etc/rc.d/courier-imap-imapd
# rm /usr/local/etc/rc.d/courier-imap-imapd-ssl
Make sure the following two lines are deleted from /etc/rc.conf
Enable_courier-imap-imapd="YES"
Enable_courier-imap-imapd-ssl="YES"
This last bit is VERY important, we dont want courier-imap trying to start twice with the next reboot, be sure and take the command to start the service OUT of /etc/rc.conf.
Now we want to make service directories for courier-imap just like you did for courierpassd
# cd /var/qmail/svc
# mkdir /var/log/courier-imap
# mkdir -m 1755 courier-imap
# cd courier-imap
# cp /root/qmail/courier-imap-run run
# chmod 755 run
# mkdir -m 755 log
# cd log
# cp /root/qmail/service-any-log-run run
# chmod 755 run
# vi run
In the run file change the second-to-last line to match the following:
multilog t n1024 s1048576 /var/log/courier-imap \
Now we link the courier-imap to service:
# ln -s /var/qmail/svc/courier-imap /service/courier-imap
Wait about 5 seconds and then run the following command:
# svstat /service/courier-imap/ /service/courier-imap/log/
If you want to run an imap ssl service you can, but you need to set that up separately from the stock imap service. I use both, I set up the plain imap service bound to the localhost address only, that way only my web mail (and any local service) can access it. the ssl service is for all your public interfaces.
# cd /var/qmail/svc
# mkdir /var/log/courier-imap-ssl
# mkdir -m 1755 courier-imap-ssl
# cd courier-imap-ssl
# cp /root/qmail/courier-imap-ssl-run run
# chmod 755 run
# mkdir -m 755 log
# cd log
# cp /root/qmail/service-any-log-run run
# chmod 755 run
# vi run
In the run file change the second-to-last line to match the following:
multilog t n1024 s1048576 /var/log/courier-imap-ssl \
Now link your imap-ssl service so daemontools will start it.
# ln -s /var/qmail/svc/courier-imap-ssl /service/courier-imap-ssl
Wait about 5 seconds and then run the following command:
# svstat /service/courier-imap-ssl/ /service/courier-imap-ssl/log/
Once the courier daemons are started, we can move on to rainloop!