diff --git a/etc/debian11/000-default.conf b/etc/debian11/000-default.conf index 4555d845..aa96e041 100644 --- a/etc/debian11/000-default.conf +++ b/etc/debian11/000-default.conf @@ -1,39 +1,39 @@ - # The ServerName directive sets the request scheme, hostname and port that - # the server uses to identify itself. This is used when creating - # redirection URLs. In the context of virtual hosts, the ServerName - # specifies what hostname must appear in the request's Host: header to - # match this virtual host. For the default virtual host (this file) this - # value is not decisive as it is used as a last resort host regardless. - # However, you must set it for any further virtual host explicitly. - #ServerName www.example.com + # The ServerName directive sets the request scheme, hostname and port that + # the server uses to identify itself. This is used when creating + # redirection URLs. In the context of virtual hosts, the ServerName + # specifies what hostname must appear in the request's Host: header to + # match this virtual host. For the default virtual host (this file) this + # value is not decisive as it is used as a last resort host regardless. + # However, you must set it for any further virtual host explicitly. + #ServerName www.example.com - ServerAdmin webmaster@localhost + ServerAdmin webmaster@localhost - LoadTileConfigFile /etc/renderd.conf - ModTileRenderdSocketName /var/run/renderd/renderd.sock - # Timeout before giving up for a tile to be rendered - ModTileRequestTimeout 0 - # Timeout before giving up for a tile to be rendered that is otherwise missing - ModTileMissingRequestTimeout 30 + LoadTileConfigFile /etc/renderd.conf + ModTileRenderdSocketName /var/run/renderd/renderd.sock + # Timeout before giving up for a tile to be rendered + ModTileRequestTimeout 0 + # Timeout before giving up for a tile to be rendered that is otherwise missing + ModTileMissingRequestTimeout 30 - DocumentRoot /var/www/html + DocumentRoot /var/www/html - # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, - # error, crit, alert, emerg. - # It is also possible to configure the loglevel for particular - # modules, e.g. - #LogLevel info ssl:warn + # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, + # error, crit, alert, emerg. + # It is also possible to configure the loglevel for particular + # modules, e.g. + #LogLevel info ssl:warn - ErrorLog ${APACHE_LOG_DIR}/error.log - CustomLog ${APACHE_LOG_DIR}/access.log combined + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined - # For most configuration files from conf-available/, which are - # enabled or disabled at a global level, it is possible to - # include a line for only one particular virtual host. For example the - # following line enables the CGI configuration for this host only - # after it has been globally disabled with "a2disconf". - #Include conf-available/serve-cgi-bin.conf + # For most configuration files from conf-available/, which are + # enabled or disabled at a global level, it is possible to + # include a line for only one particular virtual host. For example the + # following line enables the CGI configuration for this host only + # after it has been globally disabled with "a2disconf". + #Include conf-available/serve-cgi-bin.conf # vim: syntax=apache ts=4 sw=4 sts=4 sr noet diff --git a/etc/debian11/renderd.service b/etc/debian11/renderd.service new file mode 100644 index 00000000..6447c505 --- /dev/null +++ b/etc/debian11/renderd.service @@ -0,0 +1,11 @@ +[Unit] +Description=Daemon that renders map tiles using mapnik +Documentation=man:renderd +After=network.target auditd.service + +[Service] +ExecStart=/usr/bin/renderd -f -c /etc/renderd.conf +User=wrolpi + +[Install] +WantedBy=multi-user.target diff --git a/pi-gen/stage2/04-wrolpi/03-run-chroot.sh b/pi-gen/stage2/04-wrolpi/03-run-chroot.sh index 530041ef..f4c86bcf 100755 --- a/pi-gen/stage2/04-wrolpi/03-run-chroot.sh +++ b/pi-gen/stage2/04-wrolpi/03-run-chroot.sh @@ -12,7 +12,7 @@ single-file --version || npm i -g serve@12.0.1 single-file-cli@1.0.15 'git+https # Put the latest WROLPi release in /opt/wrolpi. rm -rf /opt/wrolpi -git clone -b release https://github.com/lrnselfreliance/wrolpi.git /opt/wrolpi +git clone -b master https://github.com/lrnselfreliance/wrolpi.git /opt/wrolpi chown -R ${FIRST_USER_NAME}:${FIRST_USER_NAME} /opt/wrolpi # Install Python requirements. diff --git a/pi-gen/stage2/04-wrolpi/04-run-chroot.sh b/pi-gen/stage2/04-wrolpi/04-run-chroot.sh index b2d8823a..34cb2a3d 100755 --- a/pi-gen/stage2/04-wrolpi/04-run-chroot.sh +++ b/pi-gen/stage2/04-wrolpi/04-run-chroot.sh @@ -3,9 +3,6 @@ set -e set -x -[ ! -d /var/lib/mod_tile ] && mkdir /var/lib/mod_tile -chown -R _renderd:_renderd /var/lib/mod_tile - # Initialize gis database. if [ ! -d /opt/openstreetmap-carto ]; then git clone https://github.com/lrnselfreliance/openstreetmap-carto.git /opt/openstreetmap-carto @@ -17,33 +14,20 @@ if [[ ! -f /opt/openstreetmap-carto/mapnik.xml || ! -s /opt/openstreetmap-carto/ /usr/bin/carto project.mml >/opt/openstreetmap-carto/mapnik.xml fi -cat > /etc/renderd.conf << 'EOF' -[renderd] -stats_file=/run/renderd/renderd.stats -socketname=/run/renderd/renderd.sock -num_threads=4 -tile_dir=/var/cache/renderd/tiles +# Configure renderd. +cp /opt/wrolpi/etc/debian11/renderd.conf /etc/renderd.conf +# Configure Apache2 to listen on 8084. +cp /opt/wrolpi/etc/debian11/ports.conf /etc/apache2/ports.conf +cp /opt/wrolpi/etc/debian11/000-default.conf /etc/apache2/sites-available/000-default.conf +# Copy Leaflet files to Apache's directory so they can be used offline. +cp /opt/wrolpi/etc/debian11/index.html \ + /opt/wrolpi/modules/map/leaflet.js \ + /opt/wrolpi/modules/map/leaflet.css /var/www/html/ +chmod 644 /var/www/html/* -[mapnik] -plugins_dir=/usr/lib/mapnik/3.1/input -font_dir=/usr/share/fonts/truetype -font_dir_recurse=true - -[ajt] -URI=/hot/ -TILEDIR=/var/lib/mod_tile -XML=/opt/openstreetmap-carto/mapnik.xml -HOST=localhost -TILESIZE=256 -MAXZOOM=20 -EOF - -cp /opt/wrolpi/etc/ubuntu20.04/mod_tile.conf /etc/apache2/conf-available/mod_tile.conf -cp /opt/wrolpi/modules/map/leaflet.js /var/www/html/leaflet.js -cp /opt/wrolpi/modules/map/leaflet.css /var/www/html/leaflet.css -cp /opt/wrolpi/etc/ubuntu20.04/ports.conf /etc/apache2/ports.conf -cp /opt/wrolpi/etc/ubuntu20.04/000-default.conf /etc/apache2/sites-available/000-default.conf -cp /opt/wrolpi/etc/ubuntu20.04/index.html /var/www/html/index.html +# mod_tile needs to be accessbile to renderd. +[ ! -d /var/lib/mod_tile ] && mkdir /var/lib/mod_tile +chown -R _renderd:_renderd /var/lib/mod_tile # Enable mod-tile. /usr/sbin/a2enconf mod_tile diff --git a/scripts/create_db.sh b/scripts/create_db.sh index 1d22ca0c..9d7430f8 100755 --- a/scripts/create_db.sh +++ b/scripts/create_db.sh @@ -12,14 +12,17 @@ sudo -u wrolpi /bin/bash -c 'cd /opt/wrolpi && ./main.py db upgrade' # Create gis (map) database. sudo -u postgres psql -c '\l' | grep gis || ( - sudo -u postgres createuser _renderd - sudo -u postgres createdb -E UTF8 -O _renderd gis + sudo -u postgres createuser wrolpi + sudo -u postgres createdb -E UTF8 -O wrolpi gis sudo -u postgres psql -d gis -c "CREATE EXTENSION postgis" sudo -u postgres psql -d gis -c "CREATE EXTENSION hstore" - sudo -u postgres psql -d gis -c "ALTER TABLE geometry_columns OWNER TO _renderd" - sudo -u postgres psql -d gis -c "ALTER TABLE spatial_ref_sys OWNER TO _renderd" echo "Created gis database" ) # Restore initial dump. -zcat /opt/wrolpi-blobs/gis-map.dump.gz | sudo -u _renderd pg_restore --no-owner --role=_renderd -d gis -sudo -u postgres psql gis -c 'ALTER TABLE geography_columns OWNER TO _renderd' +zcat /opt/wrolpi-blobs/gis-map.dump.gz | sudo -u wrolpi pg_restore --no-owner --role=wrolpi -d gis +sudo -u postgres psql gis -c 'ALTER TABLE geography_columns OWNER TO wrolpi' +sudo -u postgres psql -d gis -c "ALTER TABLE spatial_ref_sys OWNER TO wrolpi" +# Restore ownership of map files. +sudo chown -R wrolpi:wrolpi /var/lib/mod_tile /run/renderd +# Clear map tile cache files. +[ -d /var/lib/mod_tile/ajt ] && sudo rm -r /var/lib/mod_tile/ajt diff --git a/scripts/import_map.sh b/scripts/import_map.sh index f2d8248d..7c464f0d 100755 --- a/scripts/import_map.sh +++ b/scripts/import_map.sh @@ -20,7 +20,7 @@ fi HAS_ICE_SHEET=false psql gis wrolpi -c '\d' | grep icesheet_polygons && HAS_ICE_SHEET=true if [ ${HAS_ICE_SHEET} = false ]; then - echo "Missing icesheet_polygons. Run reset_map.sh" + echo "WROLPi: Missing icesheet_polygons. Run reset_map.sh" exit 4 fi @@ -37,11 +37,11 @@ if [[ ${1} == *.osm.pbf ]]; then # Import PBF files. for i in "$@"; do if [[ $i != *.osm.pbf ]]; then - echo "Cannot mix file types" + echo "WROLPi: Cannot mix file types" exit 5 fi if [ ! -f "${i}" ]; then - echo "File does not exist! ${i}" + echo "WROLPi: File does not exist! ${i}" exit 6 fi done @@ -66,12 +66,12 @@ if [[ ${1} == *.osm.pbf ]]; then "${pbf_path}" elif [[ ${1} == *.dump ]]; then if [ ! -f "${1}" ]; then - echo "File does not exist! ${1}" + echo "WROLPi: File does not exist! ${1}" exit 7 fi # Import a Postgresql dump. nice -n 18 pg_restore -j3 --no-owner -d gis "${1}" else - echo "Cannot import unknown map file" + echo "WROLPi: Cannot import unknown map file" exit 8 fi