#!/bin/sh set -e OS_WEBROOT_CONF_PATH="/etc/openstack-dashboard/local_settings.d/_0005_debian_webroot.py" # We need to check if WEBROOT config will be changed # If yes, we need to exec compress,collect_static. # If no, it isn't needed. change_webroot (){ WEBROOT=$1 # If WEBROOT config exist, compare it if [ -e ${OS_WEBROOT_CONF_PATH} ]; then CURRENT_WEBROOT=$(cat ${OS_WEBROOT_CONF_PATH} | grep ^WEBROOT | sed -e 's/"*'\''*\ *//g' | awk -F '=' '{print $2}') if [ "${CURRENT_WEBROOT}" = "${WEBROOT}" ]; then echo "===> openstack-dashboard-apache: Webroot already set." echo "===> openstack-dashboard-apache: Rebuild static not needed." else sed -i "s|^[ \t]*WEBROOT[ \t]=.*|WEBROOT = \"${WEBROOT}\"|" ${OS_WEBROOT_CONF_PATH} echo "===> openstack-dashboard-apache: Setting Horizon's webroot to ${WEBROOT}" echo "===> openstack-dashboard-apache: Horizon's webroot was changed, rebuild static is needed." dpkg-trigger --no-await openstack-dashboard-rebuild-static fi fi } if [ "$1" = "configure" ] ; then . /usr/share/debconf/confmodule if ! [ -f /etc/default/openstack-dashboard-apache ] ; then echo "# This file controls the behavior of the # Apache installation / upgrade. # Controls if the Apache \"default\" site provided by the Debian # Apache package should be disabled, and the \"openstack-dashboard\" # virtual host enabled. If set to no, then you will have to do the # setup manually. HORIZON_ACTIVATE_VHOSTS=yes # If the above HORIZON_ACTIVATE_VHOSTS is set to yes, the # below directive is set to yes also, then Horizon will # be setup using SSL, and any query to the non-SSL site # will be redirected to the SSL site. HORIZON_USE_SSL=yes" >/etc/default/openstack-dashboard-apache fi db_get horizon/activate_vhost if [ "${RET}" = "true" ] && [ -x /etc/init.d/apache2 ] ; then sed -i 's#[ \t]*HORIZON_ACTIVATE_VHOSTS=.*#HORIZON_ACTIVATE_VHOSTS=yes#' /etc/default/openstack-dashboard-apache # Set webroot to / in openstack-dashboard settings change_webroot "/" a2dissite 000-default.conf || true a2dissite default-ssl.conf || true db_get horizon/use_ssl if [ "${RET}" = "true" ] ; then sed -i 's#[ \t]*HORIZON_USE_SSL=.*#HORIZON_USE_SSL=yes#' /etc/default/openstack-dashboard-apache a2enmod ssl a2enmod rewrite a2dissite openstack-dashboard.conf a2dissite openstack-dashboard-alias-only.conf a2ensite openstack-dashboard-ssl-redirect.conf a2ensite openstack-dashboard-ssl.conf else sed -i 's#[ \t]*HORIZON_USE_SSL=.*#HORIZON_USE_SSL=no#' /etc/default/openstack-dashboard-apache a2dissite openstack-dashboard-ssl.conf a2dissite openstack-dashboard-ssl-redirect.conf a2dissite openstack-dashboard-alias-only.conf a2ensite openstack-dashboard.conf fi if [ -L /usr/share/openstack-dashboard/static ]; then if ! [ $(readlink -s /usr/share/openstack-dashboard/static) = /var/lib/openstack-dashboard/static ]; then ln -fs /var/lib/openstack-dashboard/static /usr/share/openstack-dashboard/static fi else ln -fs /var/lib/openstack-dashboard/static /usr/share/openstack-dashboard/static fi invoke-rc.d --quiet apache2 reload || true else sed -i 's#[ \t]*HORIZON_ACTIVATE_VHOSTS=.*#HORIZON_ACTIVATE_VHOSTS=no#' /etc/default/openstack-dashboard-apache # Set webroot to /horizon in openstack-dashboard settings change_webroot "/horizon" a2ensite 000-default.conf || true a2ensite default-ssl.conf || true a2dissite openstack-dashboard.conf || true a2dissite openstack-dashboard-ssl-redirect.conf || true a2dissite openstack-dashboard-ssl.conf || true a2ensite openstack-dashboard-alias-only.conf || true invoke-rc.d --quiet apache2 reload || true fi db_stop fi exit 0