#!/bin/bash -e echo "Running configure.sh" echo "Generating directory for seeding logs" mkdir -p "${INSTALL_DIR}" cd "${INSTALL_DIR}" cat /mapcache-template.xml \ | sed -e "s/{{ST_AUTH_VERSION}}/$(echo ${ST_AUTH_VERSION} | sed -e 's/[]\/$*.^[]/\\&/g')/g" \ | sed -e "s/{{OS_AUTH_URL_SHORT}}/$(echo ${OS_AUTH_URL_SHORT} | sed -e 's/[]\/$*.^[]/\\&/g')/g" \ | sed -e "s/{{OS_TENANT_NAME}}/$(echo ${OS_TENANT_NAME} | sed -e 's/[]\/$*.^[]/\\&/g')/g" \ | sed -e "s/{{OS_TENANT_ID}}/$(echo ${OS_TENANT_ID} | sed -e 's/[]\/$*.^[]/\\&/g')/g" \ | sed -e "s/{{OS_USERNAME}}/$(echo ${OS_USERNAME} | sed -e 's/[]\/$*.^[]/\\&/g')/g" \ | sed -e "s/{{OS_PASSWORD}}/$(echo ${OS_PASSWORD} | sed -e 's/[]\/$*.^[]/\\&/g')/g" \ | sed -e "s/{{BUCKET_NAME}}/$(echo ${BUCKET_NAME} | sed -e 's/[]\/$*.^[]/\\&/g')/g" \ | sed -e "s/{{BUCKET_NAME_FULL}}/$(echo ${BUCKET_NAME_FULL} | sed -e 's/[]\/$*.^[]/\\&/g')/g" \ | sed -e "s/{{DB_USER}}/$(echo ${DB_USER} | sed -e 's/[]\/$*.^[]/\\&/g')/g" \ | sed -e "s/{{DB_PW}}/$(echo ${DB_PW} | sed -e 's/[]\/$*.^[]/\\&/g')/g" \ | sed -e "s/{{DB_HOST}}/$(echo ${DB_HOST} | sed -e 's/[]\/$*.^[]/\\&/g')/g" \ | sed -e "s/{{DB_PORT}}/$(echo ${DB_PORT} | sed -e 's/[]\/$*.^[]/\\&/g')/g" \ | sed -e "s/{{DB_NAME}}/$(echo ${DB_NAME} | sed -e 's/[]\/$*.^[]/\\&/g')/g" \ | sed -e "s;http://localhost/ows;http://${RENDERER_HOST}/ows;" > mapcache.xml cd - chown -R www-data:www-data "${INSTALL_DIR}" mkdir -p "/cache-db/${COLLECTION}" if [ ! -f "${APACHE_CONF}" ] ; then echo "Adding Apache configuration" # Log to stderr if ! grep -Fxq "ErrorLog /proc/self/fd/2" /etc/apache2/apache2.conf ; then sed -e 's,^ErrorLog .*$,ErrorLog /proc/self/fd/2,' -i /etc/apache2/apache2.conf fi # Enable & configure Keepalive if ! grep -Fxq "KeepAlive On" /etc/apache2/apache2.conf ; then sed -e 's/^KeepAlive .*$/KeepAlive On/' -i /etc/apache2/apache2.conf fi if ! grep -Fxq "MaxKeepAliveRequests 0" /etc/apache2/apache2.conf ; then sed -e 's/^MaxKeepAliveRequests .*$/MaxKeepAliveRequests 0/' -i /etc/apache2/apache2.conf fi if ! grep -Fxq "KeepAliveTimeout 5" /etc/apache2/apache2.conf ; then sed -e 's/^KeepAliveTimeout .*$/KeepAliveTimeout 5/' -i /etc/apache2/apache2.conf fi # Enlarge timeout setting for ingestion of full resolution images if ! grep -Fxq "Timeout 1800" /etc/apache2/apache2.conf ; then sed -e 's/^Timeout .*$/Timeout 1800/' -i /etc/apache2/apache2.conf fi # TODO optimize Apache configuration like MPM in combination with Docker Swarm a2dissite 000-default a2enmod headers MAPCACHE_CONF=`echo ${INSTALL_DIR}/mapcache.xml | sed -e 's;//;/;g'` cat << EOF > "${APACHE_CONF}" <VirtualHost *:80> ServerName ${APACHE_ServerName} ServerAdmin ${APACHE_ServerAdmin} DocumentRoot ${INSTALL_DIR} <Directory "${INSTALL_DIR}"> Options -Indexes +FollowSymLinks Require all granted Header set Access-Control-Allow-Origin * </Directory> MapCacheAlias $APACHE_NGEO_CACHE_ALIAS "${MAPCACHE_CONF}" ErrorLog /proc/self/fd/2 ServerSignature Off LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %D" ngeo CustomLog /proc/self/fd/1 ngeo </VirtualHost> EOF else echo "Using existing Apache configuration" fi if [ ! -f "${INSTALL_DIR}/index.html" ] ; then echo "Adding index.html to replace Apache HTTP server test page" cat << EOF > "${INSTALL_DIR}/index.html" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html> <head> <title>PRISM View Server (PVS) - Cache</title> </head> <body> <h1>PRISM View Server (PVS) - Cache Test Page<br><font size="-1"> <strong>powered by</font> <a href="https://eox.at">EOX</a></strong></h1> <p>This page is used to test the proper operation of the PRISM View Server (PVS) cache after it has been installed. If you can read this page it means that the PRISM View Server (PVS) cache installed at this site is working properly.</p> <p>Links to services:</p> <ul> <li><a href="/cache${APACHE_NGEO_CACHE_ALIAS}/wmts/1.0.0/WMTSCapabilities.xml">PVS WMTS</a></li> <li><a href="/cache${APACHE_NGEO_CACHE_ALIAS}?SERVICE=WMS&REQUEST=GetCapabilities">PVS WMS</a></li> </ul> </body> </html> EOF else echo "Using existing index.html" fi # create a database view for the mapcache items echo "Creating database view for mapcache items" psql "host=${DB_HOST} user=${DB_USER} password=${DB_PW} dbname=${DB_NAME} port=${DB_PORT}" -f /mapcache_items_view.sql