[buildout]

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

parts =
    publish
    rootfs
    uuid
    lxc-conf
    shellinabox
    certificate-authority
    ca-shellinabox
    container-promise
    shellinabox-promise
    rootfs-promise


[rootdirectory]
recipe = slapos.cookbook:mkdirectory
etc = $${buildout:directory}/etc
tmp = $${buildout:directory}/tmp
srv = $${buildout:directory}/srv
bin = $${buildout:directory}/bin

[basedirectory]
recipe = slapos.cookbook:mkdirectory
services = $${rootdirectory:etc}/run
promises = $${rootdirectory:etc}/promise

[directory]
recipe = slapos.cookbook:mkdirectory
shellinabox = $${rootdirectory:srv}/shellinabox/
ca-dir = $${rootdirectory:srv}/ca/

[cadirectory]
recipe = slapos.cookbook:mkdirectory
requests = $${directory:ca-dir}/requests/
private = $${directory:ca-dir}/private/
certs = $${directory:ca-dir}/certs/
newcerts = $${directory:ca-dir}/newcerts/
crl = $${directory:ca-dir}/crl/

[cadirectory]
recipe = slapos.cookbook:mkdirectory
requests = $${directory:ca-dir}/requests/
private = $${directory:ca-dir}/private/
certs = $${directory:ca-dir}/certs/
newcerts = $${directory:ca-dir}/newcerts/
crl = $${directory:ca-dir}/crl/

[rootfs]
recipe = slapos.cookbook:downloader
url = $${slap-parameter:rootfs}
md5sum = $${slap-parameter:rootfs-md5sum}
downloaded-file = $${rootdirectory:srv}/rootfs.img
downloaded-file-complete = $${:downloaded-file}.complete
binary = $${basedirectory:services}/rootfsdownload
path = ${tar:location}/bin/:${gzip:location}/bin/:${bzip2:location}/bin/:${xz-utils:location}/bin/
archive = true

[lxc-conf]
recipe = slapos.recipe.template
url = ${lxc-conf-in:location}/${lxc-conf-in:filename}
output = $${rootdirectory:etc}/lxc.conf
bridge = !!BRIDGE_NAME!!
interface = lxc$${slap-network-information:network-interface}

[passwd]
recipe = slapos.cookbook:generate.password
storage-path = $${buildout:directory}/.password

[shellinabox]
recipe = slapos.cookbook:shellinabox
ipv6 = $${slap-network-information:global-ipv6}
port = 8080
shell = ${lxc:location}/bin/lxc-console -n $${uuid:uuid}
wrapper = $${rootdirectory:bin}/shellinaboxd_raw
shellinabox-binary = ${shellinabox:location}/bin/shellinaboxd
password = $${passwd:passwd}
directory = $${buildout:directory}/
login-shell = $${rootdirectory:bin}/login
certificate-directory = $${directory:shellinabox}
cert-file = $${directory:shellinabox}/public.crt
key-file = $${directory:shellinabox}/private.key

[ca-shellinabox]
<= certificate-authority
recipe = slapos.cookbook:certificate_authority.request
executable = $${shellinabox:wrapper}
wrapper = $${rootdirectory:bin}/shellinaboxd
key-file = $${shellinabox:key-file}
cert-file = $${shellinabox:cert-file}

[certificate-authority]
recipe = slapos.cookbook:certificate_authority
openssl-binary = ${openssl:location}/bin/openssl
ca-dir = $${directory:ca-dir}
requests-directory = $${cadirectory:requests}
wrapper = $${basedirectory:services}/ca
ca-private = $${cadirectory:private}
ca-certs = $${cadirectory:certs}
ca-newcerts = $${cadirectory:newcerts}
ca-crl = $${cadirectory:crl}

[ca-shellinabox]
<= certificate-authority
recipe = slapos.cookbook:certificate_authority.request
executable = $${shellinabox:wrapper}
wrapper = $${rootdirectory:bin}/shellinaboxd
key-file = $${shellinabox:key-file}
cert-file = $${shellinabox:cert-file}

[uuid]
recipe = slapos.cookbook:uuid
cache-file = $${buildout:directory}/.slapcontainername

[publish]
recipe = slapos.cookbook:publish
url = https://[$${shellinabox:ipv6}]:$${shellinabox:port}/
password = $${shellinabox:password}

[template-promise-state]
recipe = slapos.recipe.template
url = ${promise-state:location}/${promise-state:filename}
bash = ${bash:location}/bin/bash
test-binary = ${coreutils:location}/bin/test
cat = ${coreutils:location}/bin/cat
value = started
mode = 700

[container-promise]
<= template-promise-state
output = $${basedirectory:promises}/slapcontainer
file = $${buildout:directory}/.slapcontainer.state

[shellinabox-promise]
<= template-promise-state
output = $${basedirectory:promises}/shellinabox
file = $${buildout:directory}/.shellinabox.state

[rootfs-promise]
recipe = slapos.recipe.template
url = ${promise-exists:location}/${promise-exists:filename}
output = $${basedirectory:promises}/rootfs
bash = ${bash:location}/bin/bash
test-binary = ${coreutils:location}/bin/test
file = $${rootfs:downloaded-file-complete}
mode = 700

[slap-parameter]
rootfs-md5sum =
