Browse Source

Add cronjob to update site icon spritesheet

Automatically runs the generate-site-icons script every 5 minutes. The
script was also updated to use checksum-based rsync instead of cp, so
that the file won't be replaced (and need to be redownloaded by users)
unless it actually changes.
merge-requests/40/head
Deimos 6 years ago
parent
commit
87d7db4169
  1. 8
      salt/salt/cronjobs.sls
  2. 2
      salt/salt/scripts/generate-site-icons.sh.jinja2

8
salt/salt/cronjobs.sls

@ -1,7 +1,13 @@
{% from 'common.jinja2' import app_dir, bin_dir %}
{% from 'common.jinja2' import app_dir, app_username, bin_dir %}
data-cleanup-cronjob: data-cleanup-cronjob:
cron.present: cron.present:
- name: {{ bin_dir }}/python -c "from scripts.clean_private_data import clean_all_data; clean_all_data('{{ app_dir }}/{{ pillar['ini_file'] }}')" - name: {{ bin_dir }}/python -c "from scripts.clean_private_data import clean_all_data; clean_all_data('{{ app_dir }}/{{ pillar['ini_file'] }}')"
- hour: 4 - hour: 4
- minute: 10 - minute: 10
generate-site-icons-cronjob:
cron.present:
- name: /usr/local/bin/generate-site-icons
- user: {{ app_username }}
- minute: '*/5'

2
salt/salt/scripts/generate-site-icons.sh.jinja2

@ -2,4 +2,4 @@
{% from 'site-icons-spriter.sls' import site_icons_venv_dir, site_icons_data_dir -%} {% from 'site-icons-spriter.sls' import site_icons_venv_dir, site_icons_data_dir -%}
#!/bin/bash #!/bin/bash
{{ site_icons_venv_dir }}/bin/glue --sprite-namespace= --namespace= --retina --css-template={{ app_dir }}/scripts/site-icons-spriter/css_template.jinja2 {{ site_icons_data_dir }}/site-icons {{ site_icons_data_dir }}/output {{ site_icons_venv_dir }}/bin/glue --sprite-namespace= --namespace= --retina --css-template={{ app_dir }}/scripts/site-icons-spriter/css_template.jinja2 {{ site_icons_data_dir }}/site-icons {{ site_icons_data_dir }}/output
cp {{ site_icons_data_dir }}/output/*.png {{ app_dir }}/static/images
rsync --checksum {{ site_icons_data_dir }}/output/*.png {{ app_dir }}/static/images
Loading…
Cancel
Save