[buildout]

parts =
  publish-connection-informations
  cron
  certificate-authority
  cron-entry-monitor
  cron-entry-rss
  deploy-index
  deploy-settings-cgi
  deploy-status-cgi
  deploy-status-history-cgi
  setup-static-files
  certificate-authority
  zero-parameters
  public-symlink
  cgi-httpd-wrapper
  cgi-httpd-graceful-wrapper
  monitor-promise
  monitor-instance-log-access
  cron-rsync-logs
  plot-html
  dygraph-js
  
extends = ${monitor-template:output}


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

[cron-rsync-logs]
<= cron
recipe = slapos.cookbook:cron.d
name = rsync-logs
frequency = * * * * *
command = $${rsync-logs:rendered}

[rsync-logs]
recipe = slapos.recipe.template:jinja2
template = ${rsync-logs-script:output}
rendered = $${monitor-directory:bin}/rsync-logs.sh
mode = 0744
context =
  key buildout_directory buildout:directory
  raw rsync_binary ${rsync:location}/bin/rsync
  key server_log_directory monitor-directory:server-log 

[plot-html]
recipe = slapos.recipe.template:jinja2
template = ${template-plot-html:output}
rendered = $${monitor-directory:server-log}/plot.html
mode = 0644
context =

[dygraph-js]
recipe = slapos.recipe.template:jinja2
template = ${template-dygraph-js:output}
rendered = $${monitor-directory:server-log}/dygraph-combined.js
mode = 0644
context =

[pwgen]
recipe = slapos.cookbook:generate.password
user = admin
bytes = 16

[pwgen32]
recipe = slapos.cookbook:generate.password
user = admin
bytes = 16

[htpasswd-generate]
recipe = plone.recipe.command
output = $${monitor-parameters:htaccess-file}
long_passwd = $${pwgen:passwd}$${pwgen32:passwd} 
update-command = $${:command}
command =
  echo ${apache:location}/bin/htpasswd $${:output} $${pwgen:user} $${:long_passwd}
  ${apache:location}/bin/htpasswd -cb $${:output} $${pwgen:user} $${:long_passwd}

[monitor-directory]
server-log = $${:private-directory}/server-log

[monitor-parameters]
url = https://$${pwgen:user}:$${htpasswd-generate:long_passwd}@[$${slap-parameters:ipv6-random}]:$${:port}