[buildout]
extends = template-runner.cfg
          ${pbsready-import:output}

parts +=
  nginx_conf
  nginx-launcher
  certificate-authority
  ca-nginx
  gunicorn-launcher
  gunicorn-graceful
  sshkeys-dropbear-runner
  dropbear-server-add-authorized-key
  sshkeys-authority
  slaprunner-promise
  slaprunner-supervisord-wrapper
  dropbear-promise
  runtestsuite
  shellinabox
  symlinks
  slapos-cfg
  slapos-repo
  cron-entry-prepare-software
  deploy-instance-parameters
  instance-software-type
  bash-profile
  supervisord-wrapper
  importer-consistency-promise
# have to repeat the next one, as it's not inherited from pbsready-import
  import-on-notification

  monitor-base

# For the needs of importer, we run the full slaprunner
# In case both exporter and importer (aka main instance and clone instance)
# run with the same IP (usually for testing purposes),
# run slaprunner using different ports.
[slaprunner]
proxy_port = 50000
runner_port = 50005

[importer]
recipe = slapos.recipe.template:jinja2
template = ${template-runner-import-script:location}/${template-runner-import-script:filename}
rendered = $${directory:bin}/$${slap-parameter:namebase}-importer
# backward compatibility for resilient stack
wrapper = $${:rendered}
mode = 700
restore-exit-code-file=$${directory:srv}/importer-exit-code-file
context =
  key backend_url slaprunner:access-url
  key proxy_host slaprunner:ipv4
  section directory directory
  raw  shell_binary ${dash:location}/bin/dash
  raw  rsync_binary ${rsync:location}/bin/rsync
  raw  restore_exit_code_file $${:restore-exit-code-file}

[importer-consistency-promise]
# Test that the importer script and "after-import" subscripts:
# 1/ Have been run in the last 24 hours
# 2/ Have succeeded
recipe = collective.recipe.template
input = inline: #!/bin/sh
  EXIT_CODE_FILE=$(find "$${importer:restore-exit-code-file}" -mtime -1)
  if [ -z "$EXIT_CODE_FILE" ]; then
     echo "Consistency check is too old."
     exit 1
   fi
  EXIT_CODE=$(cat $EXIT_CODE_FILE)
  exit $EXIT_CODE
output = $${directory:promises}/importer-consistency-promise
mode = 755

[slap-parameter]
auto-deploy-instance = false
auto-deploy = true
name = Webrunner import
monitor-cors-domains = 
monitor-username = $${monitor-htpasswd:username}
monitor-password = $${monitor-htpasswd:passwd}

[resilient-publish-connection-parameter]
monitor-base-url = $${publish:monitor-base-url}
monitor-url = $${publish:monitor-url}
monitor-user = $${publish:monitor-user}
monitor-password = $${publish:monitor-password}


[monitor-instance-parameter]
monitor-httpd-port = 8360
#monitor-title = $${slap-parameter:name}
#cors-domains = $${slap-parameter:monitor-cors-domains}
#username = $${slap-parameter:monitor-username}
#password = $${slap-parameter:monitor-password}
# Pass some parameter to dispay in monitoring interface
instance-configuration =
  raw takeover-url http://[$${resilient-web-takeover-httpd-configuration-file:listening-ip}]:$${resilient-web-takeover-httpd-configuration-file:listening-port}/
  raw takeover-password $${resilient-web-takeover-password:passwd}

[monitor-conf-parameters]
private-path-list += 
  $${directory:logrotate-backup}
