[buildout]
parts = switch-softwaretype

# std stuff for slapos instance
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true


[switch-softwaretype]
recipe = slapos.cookbook:softwaretype
default  = $${dynamic-template-turnserver:rendered}
insecure  = $${dynamic-template-insecure-turnserver:rendered}
RootSoftwareInstance = $${:default}

[slap-configuration]
recipe = slapos.cookbook:slapconfiguration.serialised
computer = $${slap-connection:computer-id}
partition = $${slap-connection:partition-id}
url = $${slap-connection:server-url}
key = $${slap-connection:key-file}
cert = $${slap-connection:cert-file}

[jinja2-template-base]
recipe = slapos.recipe.template:jinja2
rendered = $${buildout:directory}/$${:filename}
extensions = jinja2.ext.do
mode = 0644
extra-context =
context =
  key develop_eggs_directory buildout:develop-eggs-directory
  key eggs_directory buildout:eggs-directory
  key ipv4 slap-configuration:ipv4
  key ipv6 slap-configuration:ipv6
  key global_ipv4_prefix network-information:global-ipv4-network
  key slapparameter_dict slap-configuration:configuration
  key computer_id slap-configuration:computer
  raw template_monitor ${monitor2-template:rendered}
  raw logrotate_cfg ${template-logrotate-base:rendered}
  $${:extra-context}


[dynamic-template-turnserver-parameters]
openssl = ${openssl:location}
turnserver-location = ${coturn:location}


[dynamic-template-turnserver]
<= jinja2-template-base
template = ${template-turnserver:location}/${template-turnserver:filename}
filename = instance-turnserver.cfg
extra-context =
  section parameter_dict dynamic-template-turnserver-parameters

[dynamic-template-insecure-turnserver]
<= jinja2-template-base
template = ${template-insecure-turnserver:location}/${template-insecure-turnserver:filename}
filename = instance-insecure-turnserver.cfg
extra-context =
  section parameter_dict dynamic-template-turnserver-parameters