11#! /bin/bash
22
3+ set -euo pipefail
4+
35function createPostgresConfig() {
46 cp /etc/postgresql/12/main/postgresql.custom.conf.tmpl /etc/postgresql/12/main/conf.d/postgresql.custom.conf
57 sudo -u postgres echo " autovacuum = $AUTOVACUUM " >> /etc/postgresql/12/main/conf.d/postgresql.custom.conf
@@ -42,22 +44,22 @@ if [ "$1" = "import" ]; then
4244 setPostgresPassword
4345
4446 # Download Luxembourg as sample if no data is provided
45- if [ ! -f /data.osm.pbf ] && [ -z " $DOWNLOAD_PBF " ]; then
47+ if [ ! -f /data.osm.pbf ] && [ -z " ${ DOWNLOAD_PBF:- } " ]; then
4648 echo " WARNING: No import file at /data.osm.pbf, so importing Luxembourg as example..."
4749 DOWNLOAD_PBF=" https://download.geofabrik.de/europe/luxembourg-latest.osm.pbf"
4850 DOWNLOAD_POLY=" https://download.geofabrik.de/europe/luxembourg.poly"
4951 fi
5052
51- if [ -n " $DOWNLOAD_PBF " ]; then
53+ if [ -n " ${ DOWNLOAD_PBF:- } " ]; then
5254 echo " INFO: Download PBF file: $DOWNLOAD_PBF "
53- wget $WGET_ARGS " $DOWNLOAD_PBF " -O /data.osm.pbf
55+ wget ${ WGET_ARGS:- } " $DOWNLOAD_PBF " -O /data.osm.pbf
5456 if [ -n " $DOWNLOAD_POLY " ]; then
5557 echo " INFO: Download PBF-POLY file: $DOWNLOAD_POLY "
56- wget $WGET_ARGS " $DOWNLOAD_POLY " -O /data.poly
58+ wget ${ WGET_ARGS:- } " $DOWNLOAD_POLY " -O /data.poly
5759 fi
5860 fi
5961
60- if [ " $UPDATES " = " enabled" ]; then
62+ if [ " ${ UPDATES:- } " = " enabled" ]; then
6163 # determine and set osmosis_replication_timestamp (for consecutive updates)
6264 osmium fileinfo /data.osm.pbf > /var/lib/mod_tile/data.osm.pbf.info
6365 osmium fileinfo /data.osm.pbf | grep ' osmosis_replication_timestamp=' | cut -b35-44 > /var/lib/mod_tile/replication_timestamp.txt
@@ -73,7 +75,7 @@ if [ "$1" = "import" ]; then
7375 fi
7476
7577 # Import data
76- sudo -u renderer osm2pgsql -d gis --create --slim -G --hstore --tag-transform-script /home/renderer/src/openstreetmap-carto/openstreetmap-carto.lua --number-processes ${THREADS:- 4} -S /home/renderer/src/openstreetmap-carto/openstreetmap-carto.style /data.osm.pbf ${OSM2PGSQL_EXTRA_ARGS}
78+ sudo -u renderer osm2pgsql -d gis --create --slim -G --hstore --tag-transform-script /home/renderer/src/openstreetmap-carto/openstreetmap-carto.lua --number-processes ${THREADS:- 4} -S /home/renderer/src/openstreetmap-carto/openstreetmap-carto.style /data.osm.pbf ${OSM2PGSQL_EXTRA_ARGS:- }
7779
7880 # Create indexes
7981 sudo -u postgres psql -d gis -f /home/renderer/src/openstreetmap-carto/indexes.sql
@@ -98,7 +100,7 @@ if [ "$1" = "run" ]; then
98100 chown postgres:postgres /var/lib/postgresql -R
99101
100102 # Configure Apache CORS
101- if [ " $ALLOW_CORS " == " enabled" ] || [ " $ALLOW_CORS " == " 1" ]; then
103+ if [ " ${ ALLOW_CORS:- } " == " enabled" ] || [ " ${ ALLOW_CORS:- } " == " 1" ]; then
102104 echo " export APACHE_ARGUMENTS='-D ALLOW_CORS'" >> /etc/apache2/envvars
103105 fi
104106
@@ -112,7 +114,7 @@ if [ "$1" = "run" ]; then
112114 sed -i -E " s/num_threads=[0-9]+/num_threads=${THREADS:- 4} /g" /usr/local/etc/renderd.conf
113115
114116 # start cron job to trigger consecutive updates
115- if [ " $UPDATES " = " enabled" ] || [ " $UPDATES " = " 1" ]; then
117+ if [ " ${ UPDATES:- } " = " enabled" ] || [ " ${ UPDATES:- } " = " 1" ]; then
116118 /etc/init.d/cron start
117119 fi
118120
0 commit comments