}

# UNIX sockets start with a slash and are absolute paths
# you can use a maxchild=# to limit the maximum number of forks of a service
# you can use babysit=true and maxforkrate=# to keep tight tabs on the service
# most services also accept -U (limit number of reuses) and -T (timeout)
SERVICES {

        # --- Normal cyrus spool, or Murder backends ---
@!@

# get backend interface, default is ""
pre = ''
interface = baseConfig.get('mail/cyrus/murder/backend/interface')
if interface:
	ucrVariable = 'interfaces/' + interface + '/address'
	interfaceIP = baseConfig.get(ucrVariable)
	if interfaceIP:
		pre = "%s:" % interfaceIP

# imap
if baseConfig.has_key('mail/cyrus/imap') and baseConfig['mail/cyrus/imap'] == 'yes':
	maxchild = baseConfig.get('mail/cyrus/imap/maxchilds', '400')
	print ''
	print '\t# imap/imaps'
	print '\timap cmd="imapd -C /etc/imapd/imapd.conf -U 30" listen="%simap" prefork=0 maxchild=%s' % (pre, maxchild)
	print '\timaps cmd="imapd -C /etc/imapd/imapd.conf -s -U 30" listen="%simaps" prefork=0 maxchild=%s' % (pre, maxchild)

# pop
if baseConfig.has_key('mail/cyrus/pop') and baseConfig['mail/cyrus/pop'] == 'yes':
	maxchild = baseConfig.get('mail/cyrus/pop/maxchilds', '400')
	print ''
	print '\t# pop/pops'
	print '\tpop3 cmd="pop3d -C /etc/imapd/imapd.conf -U 30" listen="%spop3" prefork=0 maxchild=%s' % (pre, maxchild)
	print '\tpop3s cmd="pop3d -C /etc/imapd/imapd.conf -s -U 30" listen="%spop3s" prefork=0 maxchild=%s' % (pre, maxchild)

# lmtp
print ''
print '        # At least one form of LMTP is required for delivery'
print '        # (you must keep the Unix socket name in sync with imap.conf)'
if pre:
	print '        lmtp cmd="lmtpd -C /etc/imapd/imapd.conf" listen="%s2003" prefork=0 maxchild=20' % pre
else:
	print '        lmtp cmd="lmtpd -C /etc/imapd/imapd.conf -a" listen="localhost:2003" prefork=0 maxchild=20'
print ''

# sieve
maxchild = baseConfig.get('mail/cyrus/sieve/maxchilds', "400")
sieve_host = baseConfig.get("mail/cyrus/sieve/listen_host")
sieve_pre = "localhost:"
if sieve_host:
	if sieve_host == "all":
		sieve_pre = ""
	else:
		sieve_pre = sieve_host + ":"
sieve_port = configRegistry.get('mail/cyrus/sieve/port', '4190')

print '        # useful if you need to give users remote access to sieve'
print '        # by default, we limit this to localhost in Debian'
print '        sieve cmd="timsieved -C /etc/imapd/imapd.conf" listen="%s%s"  prefork=0 maxchild=%s' % (sieve_pre, sieve_port, maxchild) 

if configRegistry.get("mail/cyrus/mailnotifier") and configRegistry.is_true("mail/cyrus/notifyd", True):
	print ''
	print '        # mail notification service'
	print '        notify cmd="notifyd -C /etc/imapd/imapd.conf" listen="/var/run/cyrus/socket/notify" proto="udp" prefork=1'
@!@
        # ----------------------------------------------
