Commit 7427d438 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

html5as: Use Curl and Tar components to download content to be served

parent ee773e5e
......@@ -17,11 +17,11 @@
[template-cfg]
filename = instance.cfg.in
md5sum = d75185a0cfeced8aa41d51e1b798d9af
md5sum = 9b8dd44e9a802648840a7116dea05b95
[instance_html5as]
_update_hash_filename_ = instance_html5as.cfg.in
md5sum = 9c023bac9fb0db71213c5d31bd6a0b6b
md5sum = ea736fd96ca62b388e036ae6dbaeb73d
[template_nginx_conf]
_update_hash_filename_ = templates/nginx_conf.in
......
......@@ -9,6 +9,8 @@ offline = true
[profile-common]
nginx_location = {{ nginx_location }}
dash_location = {{ dash_location }}
tar_location = {{ tar_location }}
curl_location = {{ curl_location }}
template_nginx_conf = {{ template_nginx_conf_target }}
template_mime_types = {{ template_mime_types_target }}
template_launcher = {{ template_launcher_target }}
......
......@@ -89,6 +89,8 @@ path_nginx_conf = ${directory:etc}/nginx.conf
path_mime_types = ${directory:etc}/mime_types
# Binaries
path_shell = {{ parameter_list['dash_location'] }}/bin/dash
curl-binary = {{ parameter_list['curl_location'] }}/bin/curl
tar-binary = {{ parameter_list['tar_location'] }}/bin/tar
# Executables
bin_launcher = ${basedirectory:script}/launcher
......@@ -120,10 +122,23 @@ mode = 700
context =
section param_html5as html5as
# Simple command to put content in the docroot
# Command to put content in the docroot
[downloader]
recipe = plone.recipe.command
command = rm -r ${html5as:docroot}/*; cp ${default_index_html:rendered} ${html5as:docroot}/
# This section will fail if the command fails.
stop-on-error = true
# If a tarball is passed as a parameter in download url
# it's content will be served by the instance.
# If the parameter is not provided it fallback to the default template
command =
rm -rf ${html5as:docroot}/*;
URL="${slap-parameter:download_url}";
if [ -n "$URL" ];
then
${html5as:curl-binary} -Lks $URL | ${html5as:tar-binary} xzv -C ${html5as:docroot} --strip-components 1;
else
cp ${default_index_html:rendered} ${html5as:docroot}/;
fi
[default_index_html]
recipe = slapos.recipe.template:jinja2
......@@ -140,3 +155,4 @@ title = Title ${slap-parameter:title}!
[slap-parameter]
title =
download_url =
......@@ -11,6 +11,8 @@ extends =
# In this example we extend needed components for html5as.
../../component/nginx/buildout.cfg
../../component/dash/buildout.cfg
../../component/tar/buildout.cfg
../../component/curl/buildout.cfg
parts =
# Call installation of slapos.cookbook egg defined in stack/slapos.cfg (needed
......@@ -32,6 +34,8 @@ context =
section buildout buildout
key nginx_location nginx:location
key dash_location dash:location
key curl_location curl:location
key tar_location tar:location
key template_nginx_conf_target template_nginx_conf:target
key template_mime_types_target template_mime_types:target
key template_launcher_target template_launcher:target
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment