#!/bin/sh

set -e

if [ "$1" = "configure" ]; then

  if [ -x "`which invoke-rc.d 2>/dev/null`" -a -x "/etc/init.d/apache2" ] ; then
    invoke-rc.d --quiet apache2 reload || invoke-rc.d --quiet apache2 restart
  fi

  (
    cd /usr/share/openstack-dashboard
    echo "Collecting and compressing static assets..."
    rm -rf /usr/share/openstack-dashboard/openstack_dashboard/static/custom/* || :
    python manage.py collectstatic --noinput 2>&1 > /dev/null
    python manage.py compress --force 2>&1 > /dev/null
  )

  if [ -x "`which invoke-rc.d 2>/dev/null`" -a -x "/etc/init.d/apache2" ] ; then
    invoke-rc.d --quiet apache2 reload || invoke-rc.d --quiet apache2 restart
  fi
fi

#DEBHELPER#
