Re-generate the compressed css and js on every horizon start

The local_settings file affect django-compress behavior, so
re-generate the compressed javascript and css if it is changed

Closes-Bug: #1537815
Change-Id: I330bfb666e39ffb88a4488793562df697d5572d0
This commit is contained in:
Jeffrey Zhang 2016-01-26 00:27:58 +08:00 committed by Jeffrey Zhang
parent 436257ea84
commit 4afe624f07
2 changed files with 14 additions and 4 deletions

View File

@ -18,8 +18,7 @@ RUN yum -y install \
RUN sed -i "s|WEBROOT = '/dashboard/'|WEBROOT = '/'|" /etc/openstack-dashboard/local_settings \
&& cp /usr/share/openstack-dashboard/manage.py /usr/bin/manage.py \
&& /usr/bin/python /usr/bin/manage.py collectstatic --noinput --clear \
&& /usr/bin/python /usr/bin/manage.py compress --force
&& /usr/bin/python /usr/bin/manage.py collectstatic --noinput --clear
{% elif base_distro in ['ubuntu'] %}
@ -34,7 +33,6 @@ RUN cp /usr/share/openstack-dashboard/openstack_dashboard/conf/*.json /etc/opens
&& sed -i "s|^POLICY_FILES_PATH|POLICY_FILES_PATH = '/etc/openstack-dashboard'|" /etc/openstack-dashboard/local_settings.py \
&& cp /usr/share/openstack-dashboard/manage.py /usr/bin/manage.py \
&& /usr/bin/python /usr/bin/manage.py collectstatic --noinput \
&& /usr/bin/manage.py compress --force \
&& rm /etc/apache2/conf-enabled/openstack-dashboard.conf \
&& echo "" > /etc/apache2/ports.conf \
&& rm /etc/openstack-dashboard/local_settings.py \
@ -73,7 +71,6 @@ RUN ln -s horizon-source/* horizon \
&& cp /horizon/openstack_dashboard/local/local_settings.py.example /etc/openstack-dashboard/local_settings \
&& cp /horizon/manage.py /var/lib/kolla/venv/bin/manage.py \
&& /var/lib/kolla/venv/bin/python /var/lib/kolla/venv/bin/manage.py collectstatic --noinput --clear \
&& /var/lib/kolla/venv/bin/python /var/lib/kolla/venv/bin/manage.py compress --force \
&& chown -R horizon: /etc/openstack-dashboard /home/horizon /var/lib/kolla/venv/lib/python2.7/site-packages/static
{% endif %}

View File

@ -12,3 +12,16 @@ fi
if [[ "${KOLLA_BASE_DISTRO}" =~ fedora|centos|oraclelinux|rhel ]]; then
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
# NOTE(jeffrey4l): The local_settings file affect django-compress
# behavior, so re-generate the compressed javascript and css if it
# is changed
MD5SUM_TXT_PATH="/home/horizon/.local_settings.md5sum.txt"
if [[ ! -f ${MD5SUM_TXT_PATH} || $(md5sum -c --status ${MD5SUM_TXT_PATH};echo $?) != 0 ]]; then
md5sum /etc/openstack-dashboard/local_settings > ${MD5SUM_TXT_PATH}
if [[ "${KOLLA_INSTALL_TYPE}" == "binary" ]]; then
/usr/bin/manage.py compress --force
elif [[ "${KOLLA_INSTALL_TYPE}" == "source" ]]; then
/var/lib/kolla/venv/bin/python /var/lib/kolla/venv/bin/manage.py compress --force
fi
fi