[buildout]
parts = 
	dbmail
	dbmail_conf
	supervisor
	py


[dbmail]
recipe = iw.recipe.cmd
on_install = true
on_update = false
cmds = 
	(export LD_LIBRARY_PATH=/usr/pgsql-9.2/lib && cd ${buildout:directory}/../ && automake -a && test -f Makefile || ./configure --enable-static=yes --enable-shared=no --with-check --with-sieve --prefix=${buildout:directory} && make install)

[dbmail_conf]
recipe = iw.recipe.cmd
on_install = true
on_update = true
cmds =
	mkdir -p ${buildout:directory}/etc
	${buildout:directory}/sbin/dbmail-users -l
	sed -i -e 's/^port.*=.*\<24\>.*/port = 10024/' ${buildout:directory}/etc/dbmail.conf
	sed -i -e 's/^port.*=.*\<110\>.*/port = 10110/' ${buildout:directory}/etc/dbmail.conf
	sed -i -e 's/^port.*=.*\<143\>.*/port = 10143/' ${buildout:directory}/etc/dbmail.conf
	sed -i -e 's,^errorlog.*,errorlog = ${buildout:directory}/var/log/dbmail.err,' ${buildout:directory}/etc/dbmail.conf
	sed -i -e 's,^logfile.*,logfile = ${buildout:directory}/var/log/dbmail.log,' ${buildout:directory}/etc/dbmail.conf
	sed -i -e 's,^file_logging_levels.*,file_logging_levels = 255,' ${buildout:directory}/etc/dbmail.conf
	sed -i -e 's,^pid_directory.*,pid_directory = ${buildout:directory}/var,' ${buildout:directory}/etc/dbmail.conf
	sed -i -e 's,^dburi.*,dburi = postgresql://localhost:5432/dbmail?user=dbmail\&password=dbmail,' ${buildout:directory}/etc/dbmail.conf

[supervisor]
recipe = collective.recipe.supervisor
port = 127.0.0.1:12345
serverurl = http://127.0.0.1:12345
programs =
      10 dbmail-imapd ${buildout:directory}/sbin/dbmail-imapd [-D] true
      10 dbmail-pop3d ${buildout:directory}/sbin/dbmail-pop3d [-D] true
      10 dbmail-lmtpd ${buildout:directory}/sbin/dbmail-lmtpd [-D] true
      10 dbmail-timsieved ${buildout:directory}/sbin/dbmail-timsieved [-D] true
      10 dbmail-httpd ${buildout:directory}/sbin/dbmail-httpd [-D] true

[py]
recipe = zc.recipe.egg
eggs = pyparsing
interpreter = py
scripts = py
