#!/bin/bash -le replace_pg_params() { fn=$1 sed -i "s:__POSTGRES_HOST__:${POSTGRES_HOST}:g" $fn sed -i "s:__POSTGRES_PORT__:${POSTGRES_PORT:-"5432"}:g" $fn sed -i "s:__POSTGRES_DBNAME__:${POSTGRES_DBNAME:-"postgres"}:g" $fn sed -i "s:__POSTGRES_USER__:${POSTGRES_USER:-"postgres"}:g" $fn sed -i "s:__POSTGRES_PASSWORD_FILE__:${POSTGRES_PASSWORD_FILE:-"__POSTGRES_PASSWORD_FILE__"}:g" $fn } # Load environment variable options to overwrite in the config export LAYER_BASE_DIR=${LAYER_BASE_DIR:-"/data/tiles"} # Update the mapcache.xml file with the real host and port name mf_tmpl="/work/abi_l1b_template.map" export WMS_PLATFORMS=${WMS_PLATFORMS:-"g16 g17 g18"} export WMS_SECTORS=${WMS_SECTORS:-"radm1 radm2 radc radf"} sed -i "s:__LAYER_BASE_DIR__:$LAYER_BASE_DIR:g" /etc/apache2/sites-available/cspp_geo.conf if [[ ${POSTGRES_HOST} != "" ]]; then sed -i "s:wms_times_postgres:wms_times:g" /etc/apache2/sites-available/cspp_geo.conf replace_pg_params /usr/lib/cgi-bin/layer_times_postgres.py replace_pg_params /work/render.py else sed -i "s:wms_times_shapes:wms_times:g" /etc/apache2/sites-available/cspp_geo.conf fi python3 /work/render.py $mf_tmpl "/work/mapfiles/{platform}_abi_{sector}_l1b.map" /usr/sbin/apache2ctl configtest /usr/sbin/apache2ctl -DFOREGROUND