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

parts +=
  nginx_conf
  nginx-launcher
  certificate-authority
  ca-nginx
  ca-shellinabox
  gunicorn-launcher
  gunicorn-graceful
  sshkeys-dropbear-runner
  dropbear-server-add-authorized-key
  sshkeys-authority
  slaprunner-promise
  dropbear-promise
  runtestsuite
  shellinabox-promise
  shellinabox
  symlinks
  slapos-cfg
  slapos-repo-config
  cron-entry-prepare-software
  deploy-instance-parameters
# have to repeat the next one, as it's not inherited from pbsready-import
  import-on-notification
## Monitoring part
###Parts to add for monitoring
  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
## Monitor for runner
  monitor-current-log-access
  monitor-backup-log-access
## Monitor for import runner
  monitor-latest-restored-backup

[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
context =
  key backend_url slaprunner:access-url
  section directory directory
  raw  shell_binary ${dash:location}/bin/dash
  raw  rsync_binary ${rsync:location}/bin/rsync
  raw  curl_binary ${curl:location}/bin/curl

[slap-parameter]
auto-deploy-instance = false
auto-deploy = true

[resilient-publish-connection-parameter]
monitor-url = $${monitor-parameters:url}

[monitor-backup-log-access]
< = monitor-directory-access
source = $${directory:logrotate-backup}

[monitor-latest-restored-backup]
recipe = slapos.recipe.template:jinja2
command = if [ -f $${directory:etc}/.resilient-timestamp ]; then echo "$(date -d @$(cat $${directory:etc}/.resilient-timestamp) +%c)"; else echo "No backup timestamp found"; fi
rendered = $${monitor-directory:monitoring-cgi}/latest-restored-backup
template = ${template-wrapper:output}
mode = 744
context =
  key content :command