Skip to content
Snippets Groups Projects
run.sh 1.27 KiB
#!/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"}

if [[ -n ${AWS_S3_ENDPOINT} ]] && [[ -n ${AWS_S3_ENDPOINT_PORT} ]] && [[ ${AWS_S3_ENDPOINT_PORT} -ne 80 ]]; then
    # GDAL (or Ceph?) doesn't like when the endpoint has :80 at the end
    export AWS_S3_ENDPOINT="${AWS_S3_ENDPOINT}:${AWS_S3_ENDPOINT_PORT}"
fi

# Update the mapcache.xml file with the real host and port name
mf_tmpl="/work/abi_l1b_template.map"

if [[ ${POSTGRES_HOST} != "" ]]; then
    replace_pg_params /work/render.py
fi

export GEOSPHERE_CONFIG=${GEOSPHERE_CONFIG:-"/work/geosphere_settings.yaml"}
python3 /work/render.py ${GEOSPHERE_CONFIG} $mf_tmpl "/work/mapfiles/{satellite_info[identifier]}_{instrument_info[identifier]}_{sector_info[identifier]}_{processing_level}.map"

/usr/sbin/apache2ctl configtest

/usr/sbin/apache2ctl -DFOREGROUND