Add initial meta-stx to support StarlingX build
[pti/rtp.git] / meta-stx / recipes-devtools / python / files / python-django-horizon / horizon-assets-compress
1 #!/bin/bash
2 #
3 # Copyright (c) 2017 Wind River Systems, Inc.
4 #
5 # SPDX-License-Identifier: Apache-2.0
6 #
7
8 PYTHON=`which python`
9 MANAGE="/usr/share/openstack-dashboard/manage.py"
10 STATICDIR="/www/pages/static"
11 BRANDDIR="/opt/branding"
12 APPLIEDDIR="/opt/branding/applied"
13
14 # Handle custom horizon branding
15 rm -rf ${APPLIEDDIR}
16 if ls ${BRANDDIR}/*.tgz 1> /dev/null 2>&1; then
17     LATESTBRANDING=$(ls $BRANDDIR |grep '\.tgz$' | tail -n 1)
18     mkdir -p ${APPLIEDDIR}
19     tar zxf ${BRANDDIR}/${LATESTBRANDING} -C ${APPLIEDDIR} 2>/dev/null 1>/dev/null
20     RETVAL=$?
21     if [ $RETVAL -ne 0 ]; then
22         echo "Failed to extract ${BRANDDIR}/${LATESTBRANDING}"
23     fi
24 fi
25
26 echo "Dumping static assets"
27 if [ -d ${STATICDIR} ]; then
28     COLLECTARGS=--clear
29 fi
30 ${PYTHON} -- ${MANAGE} collectstatic -v0 --noinput ${COLLECTARGS}
31
32 RETVAL=$?
33 if [ $RETVAL -ne 0 ]; then
34     echo "Failed to dump static assets."
35     exit $RETVAL
36 fi
37
38 nice -n 20 ionice -c Idle ${PYTHON} -- ${MANAGE} compress -v0
39 RETVAL=$?
40 if [ $RETVAL -ne 0 ]; then
41     echo "Failed to compress assets."
42     exit $RETVAL
43 fi