More robust bash backends using heredoc

This commit is contained in:
Marc Aymerich 2015-05-21 20:29:29 +00:00
parent 43eb744f81
commit c6a687736b
2 changed files with 14 additions and 6 deletions

View file

@ -185,12 +185,17 @@ class PHPBackend(WebAppServiceMixin, ServiceController):
listen = {{ fpm_listen | safe }}
listen.owner = {{ user }}
listen.group = {{ group }}
pm = ondemand
pm.max_requests = {{ max_requests }}
pm.max_children = {{ max_children }}
{% if request_terminate_timeout %}request_terminate_timeout = {{ request_terminate_timeout }}{% endif %}
{% for name, value in init_vars.items %}
php_admin_value[{{ name | safe }}] = {{ value | safe }}{% endfor %}
{% if request_terminate_timeout %}\
request_terminate_timeout = {{ request_terminate_timeout }}\
{% endif %}
{% for name, value in init_vars.items %}\
php_admin_value[{{ name | safe }}] = {{ value | safe }}\
{% endfor %}
"""
))
return fpm_config.render(Context(context))

View file

@ -46,10 +46,13 @@ class WordPressBackend(WebAppServiceMixin, ServiceController):
shell_exec("mkdir -p %(app_path)s
# Prevent other backends from writting here
touch %(app_path)s/.lock
filename=\\$(wget https://wordpress.org/latest.tar.gz --server-response --spider --no-check-certificate 2>&1 | grep filename | cut -d'=' -f2)
filename=\\$(wget https://wordpress.org/latest.tar.gz --server-response --spider --no-check-certificate 2>&1 \\
| grep filename | cut -d'=' -f2)
mkdir -p %(cms_cache_dir)s
if [ \\$(basename \\$(readlink %(cms_cache_dir)s/wordpress) 2> /dev/null ) != \\$filename ]; then
wget https://wordpress.org/latest.tar.gz -O - --no-check-certificate | tee %(cms_cache_dir)s/\\$filename | tar -xzvf - -C %(app_path)s --strip-components=1
if [ ! -e %(cms_cache_dir)s/wordpress ] || [ \\$(basename \\$(readlink %(cms_cache_dir)s/wordpress) 2> /dev/null ) != \\$filename ]; then
wget https://wordpress.org/latest.tar.gz -O - --no-check-certificate \\
| tee %(cms_cache_dir)s/\\$filename \\
| tar -xzvf - -C %(app_path)s --strip-components=1
rm -f %(cms_cache_dir)s/wordpress
ln -s %(cms_cache_dir)s/\\$filename %(cms_cache_dir)s/wordpress
else