[buildout]
extends =
  buildout.hash.cfg
  ../../stack/slapos.cfg
  ../../component/git/buildout.cfg
  ../../component/dash/buildout.cfg
  ../../component/lxml-python/buildout.cfg
  ../../component/apache/buildout.cfg
  ../../component/gzip/buildout.cfg
  ../../component/stunnel/buildout.cfg
  ../../component/dcron/buildout.cfg
  ../../component/logrotate/buildout.cfg
  ../../component/pycurl/buildout.cfg
  ../../component/python-cryptography/buildout.cfg
  ../../component/rdiff-backup/buildout.cfg
  ../../component/trafficserver/buildout.cfg

  ../../component/pycurl/buildout.cfg
  ../../component/nginx/buildout.cfg
  ../../stack/nodejs.cfg
# Monitoring stack (keep on bottom)
  ../../stack/monitor/buildout.cfg

parts +=
  template
  template-apache-frontend
  template-apache-replicate
  apache
  apache-antiloris

  stunnel

  dcron
  logrotate
  rdiff-backup
  nginx-push-stream-output
  npm-modules
  proxy-by-url
  http-proxy

[extra-eggs]
recipe = zc.recipe.egg
eggs =
  websockify
  erp5.util

[template]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg
output = ${buildout:directory}/template.cfg
mode = 0644

[template-apache-frontend]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-apache-frontend.cfg
output = ${buildout:directory}/template-apache-frontend.cfg
mode = 0644

[template-apache-replicate]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/instance-apache-replicate.cfg.in
mode = 0644

[download-template]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/templates/${:filename}
mode = 640

[template-slave-list]
<=download-template
filename = apache-custom-slave-list.cfg.in

[template-slave-configuration]
<=download-template
filename = custom-virtualhost.conf.in

[template-replicate-publish-slave-information]
<=download-template
filename = replicate-publish-slave-information.cfg.in

[template-apache-frontend-configuration]
<=download-template
filename = apache.conf.in

[template-custom-slave-list]
<=download-template
filename = apache-default-slave-list.cfg.in

[template-not-found-html]
<=download-template
filename = notfound.html

[template-default-virtualhost]
<=download-template
filename = 000.conf.in

[template-default-slave-virtualhost]
<=download-template
filename = default-virtualhost.conf.in

[template-cached-slave-virtualhost]
<=download-template
filename = cached-virtualhost.conf.in

[template-log-access]
<=download-template
filename = template-log-access.conf.in

[template-empty]
<=download-template
filename = empty.in

[template-wrapper]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/templates/wrapper.in
output = ${buildout:directory}/template-wrapper.cfg
mode = 0644

[template-trafficserver-records-config]
recipe = hexagonit.recipe.download
ignore-existing = true
url = ${:_profile_base_location_}/templates/trafficserver/${:filename}
location = ${buildout:parts-directory}/${:_buildout_section_name_}
filename = records.config.jinja2
download-only = true
mode = 0644

[template-trafficserver-storage-config]
recipe = hexagonit.recipe.download
ignore-existing = true
url = ${:_profile_base_location_}/templates/trafficserver/${:filename}
location = ${buildout:parts-directory}/${:_buildout_section_name_}
filename = storage.config.jinja2
download-only = true
mode = 0644

# NGINX Configuration
[template-nginx-configuration]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/templates/nginx.cfg.in
output = ${buildout:directory}/template-nginx.cfg.in
mode = 0644

[template-apache-lazy-script-call]
<=download-template
filename = apache-lazy-script-call.sh.in

[template-apache-graceful-script]
<=download-template
filename = apache-graceful-script.sh.in

[template-nginx-eventsource-slave-virtualhost]
<=download-template
filename = nginx-eventsource-slave.conf.in

[template-nginx-notebook-slave-virtualhost]
<=download-template
filename = nginx-notebook-slave.conf.in

# Migrated from KVM recipe
[http-proxy]
# https://github.com/nodejitsu/node-http-proxy
recipe = slapos.recipe.build:download-unpacked
# use upstream when merged
url = https://lab.nexedi.com/nexedi/node-http-proxy/repository/archive.zip?ref=a5d3aff428ee8d840068b439f6ce121077f1144f
md5sum = 65602466066444c718215de41f546585

[proxy-by-url]
# https://github.com/dominictarr/proxy-by-url
recipe = slapos.recipe.build:download-unpacked
# use upstream when merged
url = https://lab.nexedi.com/nexedi/proxy-by-url/repository/archive.zip?ref=59fcb11a3e00c45b4b0362e76f29653abb313072
md5sum = c383e0c5ff31b56f7987466e8304c941

[npm-modules]
recipe = plone.recipe.command
destination = ${buildout:parts-directory}/${:_buildout_section_name_}
location = ${buildout:parts-directory}/${:_buildout_section_name_}
command =
  export HOME=${:location};
  rm -fr ${:destination} &&
  mkdir -p ${:destination} &&
  cd ${:destination} &&
  ${nodejs:location}/bin/node ${nodejs:location}/bin/npm install colors@0.6.0-1 &&
  ${nodejs:location}/bin/node ${nodejs:location}/bin/npm install socket.io@0.8.7 &&
  ${nodejs:location}/bin/node ${nodejs:location}/bin/npm install socket.io-client@0.8.7 &&
  ${nodejs:location}/bin/node ${nodejs:location}/bin/npm install optimist@0.3.1 &&
  ${nodejs:location}/bin/node ${nodejs:location}/bin/npm install pkginfo@0.2.3