docker-renderd-osm/renderd/run

39 lines
1.8 KiB
Bash

#!/bin/bash
exec 2>&1
source /etc/envvars
sed -i -e "s/{{OSM_CARTO_XML_DIR}}/\/usr\/share\/mapnik\/openstreetmap-carto-$OSM_CARTO_VERSION\/style.xml/" \
-e "s/{{PLUGINS_DIR}}/\/usr\/lib\/mapnik\/3.0\/input\//" \
-e "s/{{HOST}}/localhost/" \
/usr/local/etc/renderd.conf
sed -i -e "s/{{OSM_BRIGHT_XML_DIR}}/\/usr\/share\/mapnik\/osm-bright-$OSM_BRIGHT_VERSION\/OSMBright\/style.xml/" \
/usr/local/etc/renderd.conf
# osm-carto setup
cd /usr/share/mapnik/openstreetmap-carto-$OSM_CARTO_VERSION/
cp project.mml.orig project.mml
sed -i "s/\"dbname\": \"gis\"/\"host\": \"$PG_PORT_5432_TCP_ADDR\",\n \
\"port\": \"$PG_PORT_5432_TCP_PORT\",\n \
\"user\": \"$PG_ENV_OSM_USER\",\n \
\"password\": \"$PG_ENV_OSM_PASSWORD\",\n \
\"dbname\":\"$PG_ENV_OSM_DB\"/" project.mml
carto project.mml > style.xml
# osm-bright setup
cd /usr/share/mapnik/osm-bright-$OSM_BRIGHT_VERSION/
cp configure.py.sample configure.py
# prepare configure.py
sed -i -e "s|^config\[\"path\"\].*|config\[\"path\"\] = \"$(pwd)\"|" \
-e "s/^config\[\"postgis\"\]\[\"host\"\].*/config\[\"postgis\"\]\[\"host\"\] = \"$PG_PORT_5432_TCP_ADDR\"/" \
-e "s/^config\[\"postgis\"\]\[\"port\"\].*/config\[\"postgis\"\]\[\"port\"\] = \"$PG_PORT_5432_TCP_PORT\"/" \
-e "s/^config\[\"postgis\"\]\[\"dbname\"\].*/config\[\"postgis\"\]\[\"dbname\"\] = \"$PG_ENV_OSM_DB\"/" \
-e "s/^config\[\"postgis\"\]\[\"password\"\].*/config\[\"postgis\"\]\[\"password\"\] = \"$PG_ENV_OSM_PASSWORD\"/" \
-e "s/^config\[\"postgis\"\]\[\"user\"\].*/config\[\"postgis\"\]\[\"user\"\] = \"$PG_ENV_OSM_USER\"/" configure.py
./make.py
cd OSMBright
millstone project.mml > project.local.mml
carto project.local.mml > style.xml
exec sudo -u www-data LD_LIBRARY_PATH=/usr/local/lib/ /usr/local/bin/renderd -f --config /usr/local/etc/renderd.conf