|
1 | 1 | #!/usr/bin/env sh |
2 | 2 |
|
3 | | -if [ ! -f /opt/styles/mapnik.xml ] |
4 | | -then |
5 | | - git clone https://github.com/gravitystorm/openstreetmap-carto.git --depth 1 /opt/openstreetmap-carto |
| 3 | +export DATADIR=/opt/data |
| 4 | +export FONTDIR=/opt/fonts |
| 5 | +export MAPNIK_XML=/opt/styles/mapnik.xml |
6 | 6 |
|
7 | | - cp --archive /opt/openstreetmap-carto/patterns /opt/openstreetmap-carto/symbols /opt/styles/ |
| 7 | +sed -i \ |
| 8 | + -e "s#^xml=.*#xml=${MAPNIK_XML}#Ig" \ |
| 9 | + -e "s#^pid_file=#num_threads=-1\npid_file=#Ig" \ |
| 10 | + -e "s#^font_dir=.*#font_dir=${FONTDIR}#Ig" \ |
| 11 | + /etc/renderd.conf |
8 | 12 |
|
9 | | - python3 /opt/openstreetmap-carto/scripts/get-external-data.py --cache --config /opt/openstreetmap-carto/external-data.yml --data /opt/data |
| 13 | +if [ ! -f ${MAPNIK_XML} ] |
| 14 | +then |
| 15 | + export OPENSTREETMAP_CARTO_DIR=/opt/openstreetmap-carto |
| 16 | + git clone https://github.com/openstreetmap-carto/openstreetmap-carto.git --depth 1 ${OPENSTREETMAP_CARTO_DIR} |
10 | 17 |
|
11 | | - cd /opt && /opt/openstreetmap-carto/scripts/get-fonts.sh && cd - |
| 18 | + cp --archive ${OPENSTREETMAP_CARTO_DIR}/patterns ${OPENSTREETMAP_CARTO_DIR}/symbols /opt/styles/ |
12 | 19 |
|
13 | | - psql --command "CREATE EXTENSION postgis;" --dbname "${PGDATABASE}" --host "${PGHOST}" --user "${PGUSER}" |
14 | | - psql --command "CREATE EXTENSION hstore;" --dbname "${PGDATABASE}" --host "${PGHOST}" --user "${PGUSER}" |
15 | | - psql --command "ALTER TABLE geometry_columns OWNER TO ${PGUSER};" --dbname "${PGDATABASE}" --host "${PGHOST}" --user "${PGUSER}" |
16 | | - psql --command "ALTER TABLE spatial_ref_sys OWNER TO ${PGUSER};" --dbname "${PGDATABASE}" --host "${PGHOST}" --user "${PGUSER}" |
| 20 | + export EXTERNAL_DATA_SCRIPT_FLAGS="--cache --config ${OPENSTREETMAP_CARTO_DIR}/external-data.yml --data ${DATADIR} --no-update" |
| 21 | + export OSM2PGSQL_DATAFILE="${DATADIR}/region.osm.pbf" |
17 | 22 |
|
18 | | - if [ ! -f /opt/data/region.osm.pbf ] |
| 23 | + if [ ! -f ${OSM2PGSQL_DATAFILE} ] |
19 | 24 | then |
20 | | - curl --location "${DOWNLOAD_PBF:-http://download.geofabrik.de/asia/vietnam-latest.osm.pbf}" --output /opt/data/region.osm.pbf |
| 25 | + curl --location "${DOWNLOAD_PBF:-http://download.geofabrik.de/asia/vietnam-latest.osm.pbf}" --output ${OSM2PGSQL_DATAFILE} |
21 | 26 | fi |
22 | 27 |
|
23 | | - osm2pgsql \ |
24 | | - --create \ |
25 | | - --database "${PGDATABASE}" \ |
26 | | - --host "${PGHOST}" \ |
27 | | - --hstore \ |
28 | | - --number-processes "$(nproc)" \ |
29 | | - --slim \ |
30 | | - --tag-transform-script /opt/openstreetmap-carto/openstreetmap-carto.lua \ |
31 | | - --user "${PGUSER}" \ |
32 | | - -G \ |
33 | | - -S /opt/openstreetmap-carto/openstreetmap-carto.style \ |
34 | | - /opt/data/region.osm.pbf |
35 | | - |
36 | | - psql --dbname "${PGDATABASE}" --file /opt/openstreetmap-carto/indexes.sql --host "${PGHOST}" --user "${PGUSER}" |
| 28 | + cd ${OPENSTREETMAP_CARTO_DIR} |
| 29 | + |
| 30 | + sh scripts/docker-startup.sh import |
37 | 31 |
|
38 | 32 | npm install --global carto |
39 | | - carto /opt/openstreetmap-carto/project.mml > /opt/styles/mapnik.xml |
| 33 | + carto ${OPENSTREETMAP_CARTO_DIR}/project.mml > ${MAPNIK_XML} |
40 | 34 | fi |
41 | 35 |
|
42 | | -sed -i \ |
43 | | - -e 's#/usr/share/renderd/example-map/mapnik.xml#/opt/styles/mapnik.xml#g' \ |
44 | | - -e 's/pid_file=/num_threads=-1\npid_file=/g' \ |
45 | | - -e 's#font_dir=.*#font_dir=/opt/fonts#g' \ |
46 | | - /etc/renderd.conf |
47 | | - |
48 | 36 | apachectl -e debug -k start |
49 | 37 | renderd --foreground |
0 commit comments