[buildout]
parts =
  davstorage
  publish-connection-informations
  certificate-authority
  ca-davstorage
  cron
  cron-entry-logrotate
  logrotate
  logrotate-entry-davstorage
  copy-app
  mailer-plugin
  share-url-generation
  postfix-conf
  postfix-users
  postfix-master-conf
  postfix-service
  request-frontend

eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true

[publish-connection-informations]
recipe = slapos.cookbook:publish
webdav_access = https://$${request-frontend:connection-domain}
url = https://$${request-frontend-ajaxupload:connection-domain}
webdav_user = $${davstorage:user}
webdav_password = $${davstorage:password}

[davstorage]
recipe = slapos.cookbook:davstorage
user = user
password = insecure
port_webdav = 8080
port_ajax = 8070
ip = $${slap-network-information:global-ipv6}

# Path
wrapper = $${rootdirectory:bin}/davstorage
error-log = $${directory:davstorage-log}/error.log
access-log = $${directory:davstorage-log}/access.log
pid-file = $${basedirectory:run}/davstorage.pid
lock-file = $${basedirectory:run}/davstorage.lock
davdb-lock = $${basedirectory:run}/davdb.lock
key-file = $${ca-davstorage:key-file}
cert-file = $${ca-davstorage:cert-file}
conf-file = $${directory:davstorage-conf}/davstorage.conf
htdocs = $${directory:htdocs}
root = $${buildout:directory}
email-address = admin+davstorage@vifib.net
htpasswd-file = $${directory:davstorage-conf}/davstorage.htpasswd
promise = $${basedirectory:promises}/davstorage
php-ini-dir = $${directory:php-ini-dir}
tmp-dir = $${directory:tmp-php}

# Binaries
apache-binary = ${apache:location}/bin/httpd
apache-modules-dir = ${apache:location}/modules/
apache-mime-file = ${apache:location}/conf/mime.types
apache-htpasswd = ${apache:location}/bin/htpasswd
source = ${application:location}

[certificate-authority]
recipe = slapos.cookbook:certificate_authority
openssl-binary = ${openssl:location}/bin/openssl
ca-dir = $${directory:ca-dir}
requests-directory = $${cadirectory:requests}
wrapper = $${basedirectory:services}/certificate_authority
ca-private = $${cadirectory:private}
ca-certs = $${cadirectory:certs}
ca-newcerts = $${cadirectory:newcerts}
ca-crl = $${cadirectory:crl}

[cron]
recipe = slapos.cookbook:cron
dcrond-binary = ${dcron:location}/sbin/crond
cron-entries = $${directory:cron-entries}
crontabs = $${directory:crontabs}
cronstamps = $${directory:cronstamps}
catcher = $${cron-simplelogger:wrapper}
binary = $${basedirectory:services}/crond

[logrotate]
recipe = slapos.cookbook:logrotate
# Binaries
logrotate-binary = ${logrotate:location}/usr/sbin/logrotate
gzip-binary = ${gzip:location}/bin/gzip
gunzip-binary = ${gzip:location}/bin/gunzip
# Directories
wrapper = $${rootdirectory:bin}/logrotate
conf = $${rootdirectory:etc}/logrotate.conf
logrotate-entries = $${directory:logrotate-entries}
backup = $${directory:logrotate-backup}
state-file = $${rootdirectory:srv}/logrotate.status

[cron-entry-logrotate]
<= cron
recipe = slapos.cookbook:cron.d
name = logrotate
frequency = 0 0 * * *
command = $${logrotate:wrapper}

[cron-simplelogger]
recipe = slapos.cookbook:simplelogger
wrapper = $${rootdirectory:bin}/cron_simplelogger
log = $${basedirectory:log}/crond.log


[logrotate-entry-davstorage]
<= logrotate
recipe = slapos.cookbook:logrotate.d
name = davstorage
log = $${davstorage:error-log} $${davstorage:access-log}
frequency = daily
rotate-num = 30
sharedscripts = true
notifempty = true
create = true

[cadirectory]
recipe = slapos.cookbook:mkdirectory
requests = $${directory:ca-dir}/requests/
private = $${directory:ca-dir}/private/
certs = $${directory:ca-dir}/certs/
newcerts = $${directory:ca-dir}/newcerts/
crl = $${directory:ca-dir}/crl/

[ca-davstorage]
<= certificate-authority
recipe = slapos.cookbook:certificate_authority.request
key-file = $${directory:davstorage-conf}/davstorage.key
cert-file = $${directory:davstorage-conf}/davstorage.crt
executable = $${davstorage:wrapper}
wrapper = $${basedirectory:services}/davstorage

[rootdirectory]
recipe = slapos.cookbook:mkdirectory
etc = $${buildout:directory}/etc/
var = $${buildout:directory}/var/
srv = $${buildout:directory}/srv/
bin = $${buildout:directory}/bin/
tmp = $${buildout:directory}/tmp/

[basedirectory]
recipe = slapos.cookbook:mkdirectory
log = $${rootdirectory:var}/log/
services = $${rootdirectory:etc}/run/
run = $${rootdirectory:var}/run/
backup = $${rootdirectory:srv}/backup/
promises = $${rootdirectory:etc}/promise/

[directory]
recipe = slapos.cookbook:mkdirectory
htdocs = $${rootdirectory:srv}/www/
davstorage-log = $${basedirectory:log}/davstorage/
logrotate-backup = $${basedirectory:backup}/logrotate/
logrotate-entries = $${rootdirectory:etc}/logrotate.d/
davstorage-conf = $${rootdirectory:etc}/davstorage/
ca-dir = $${rootdirectory:srv}/ssl/
cron-entries = $${rootdirectory:etc}/cron.d/
crontabs = $${rootdirectory:etc}/crontabs/
cronstamps = $${rootdirectory:etc}/cronstamps/
cronoutput = $${basedirectory:log}/cron/
php-ini-dir = $${rootdirectory:etc}/php
tmp-php = $${rootdirectory:tmp}/php
postfix-conf = $${rootdirectory:etc}/postfix
spool = $${rootdirectory:var}/spool/postfix
data =  $${rootdirectory:var}/lib/postfix
maildrop = $${directory:spool}/maildrop
active = $${directory:spool}/active
bounce = $${directory:spool}/bounce
corrupt = $${directory:spool}/corrupt
defer = $${directory:spool}/defer
deferred = $${directory:spool}/deferred
flush = $${directory:spool}/flush
hold = $${directory:spool}/hold
incoming = $${directory:spool}/incoming
private = $${directory:spool}/private
public = $${directory:spool}/public
pid = $${directory:spool}/pid
saved = $${directory:spool}/saved
trace = $${directory:spool}/trace

# Request frontend
[request-frontend-ajaxupload]
<= slap-connection
recipe = slapos.cookbook:request
name = Frontend Ajax
# XXX We have hardcoded SR URL here.
software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg
slave = true
config = url https-only
config-https-only = true
config-url = https://[$${davstorage:ip}]:$${davstorage:port_ajax}/
return = domain

[request-frontend]
<= slap-connection
recipe = slapos.cookbook:request
name = Frontend Webdav
# XXX We have hardcoded SR URL here.
software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg
slave = true
config = url https-only
config-https-only = true
config-url = https://$${davstorage:user}:$${davstorage:password}@[$${davstorage:ip}]:$${davstorage:port_webdav}/
return = domain

[copy-app]
recipe = plone.recipe.command
update-command = command
command = cp -R ${application:location}/* $${directory:htdocs}

[mailer-plugin]
recipe = slapos.recipe.template
url = ${mailer-plugin-template:location}/${mailer-plugin-template:filename}
sendmail-script = $${sendmail-script:output}
output = $${directory:htdocs}/plugins/mailer.phpmailer-lite/lib/${mailer-plugin-template:filename}
mode = 0644
md5sum = 4649b152e1f639873a03149eccc70aaf

[share-url-generation]
recipe = slapos.recipe.template
url = ${share-url-generation-template:location}/${share-url-generation-template:filename}
filename = class.AJXP_Utils.php
output = $${directory:htdocs}/core/classes/${share-url-generation-template:filename}
mode = 0644
md5sum = f681c0a0a17f4b2a0896b952e53239ed

[postfix-service]
recipe = slapos.recipe.template
url = ${postfix-service-template:location}/${postfix-service-template:filename}
python-location = ${python2.7:executable}
postfix-location = ${postfix:location}/usr/sbin/postfix
postfix-config-dir = $${directory:postfix-conf}
pid-location = $${directory:pid}/master.pid
output = $${basedirectory:services}/postfix
mode = 0755
md5sum = 9f136d6c217f26e06f7437ceeb7b0c42

[sendmail-script]
recipe = slapos.recipe.template
url = ${sendmail-script-template:location}/${sendmail-script-template:filename}
sendmail-location = ${postfix:location}/usr/sbin/sendmail
postfix-config-dir = $${directory:postfix-conf}
output = $${rootdirectory:bin}/sendmail
mode = 0755
md5sum = d2ea9ecfd653dcb0bd06c06bcaabc5df

[postfix-conf]
recipe = slapos.recipe.template
url = ${postfix-conf-template:location}/${postfix-conf-template:filename}
queue-directory = $${directory:spool}
command-directory = ${postfix:location}/usr/sbin
bin-directory =  ${postfix:location}/usr/bin
daemon-directory = ${postfix:location}/usr/libexec/postfix
data-directory = $${directory:data}
mail-owner = $${slap-connection:partition-id}
mail-group = $${slap-connection:partition-id}
ipv4 = $${slap-network-information:global-ipv6}
output = $${directory:postfix-conf}/main.cf
mode = 0644
md5sum = a72b679c523f587422f95d295de27876

[postfix-users]
recipe = plone.recipe.command
update-command = command
command = sed 's/ slappart/ slapuser/g' $${postfix-conf:output} > main.tmp && mv main.tmp $${postfix-conf:output}

[postfix-master-conf]
recipe = slapos.recipe.template
url = ${postfix-master-conf-template:location}/${postfix-master-conf-template:filename}
port = 2525
output = $${directory:postfix-conf}/master.cf
mode = 0644
md5sum = de33aa9ef530ef3c7661b914d2d1fbef

# XXX Vivien: promise not working for now
#[frontend-ajaxupload-promise]
#recipe = slapos.cookbook:check_url_available
#path = $${basedirectory:promises}/frontend-ajaxupload
#url = $${request-frontend-ajaxupload:connection-site_url}
#dash_path = ${dash:location}/bin/dash
#curl_path = ${curl:location}/bin/curl