Key changes:

- Add MapLibre GL JS viewer with light/dark themes, terrain layer,
  and embedded static map page for coordinate sharing
- Add map pin support with persistent map_pins.yaml config
- Add map region subscriptions and downloader with progress tracking,
  sourcing pre-extracted PMTiles from a cold CDN
- Add map export to PNG and GPS coordinate copy via context menu
- Add MapViewer React component alongside reworked Map page
- Add map catalog and region-building script (build_map_regions.py)
- Remove OSM import/render scripts, leaflet files, Apache configs,
  renderd service, and osm-map-dumper Docker container
- Update Caddyfile to serve PMTiles and map static assets
- Update build/install/repair scripts for Protomaps dependencies
- Drop map_file table, add/drop map_subscription table (alembic)
- Adding button to skip primary drive mounting during onboarding.
This commit is contained in:
Roland 2026-03-29 18:58:31 -06:00
parent 0a5fe7eebe
commit b8a532c8d9
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
102 changed files with 5033 additions and 2712 deletions

View file

@ -1,20 +0,0 @@
#!/usr/bin/env bash
source /opt/wrolpi/wrolpi/scripts/lib.sh
# Re-execute this script if it wasn't called with sudo.
if [ $EUID != 0 ]; then
sudo "$0" "$@"
exit $?
fi
yes_or_no "Are you sure you want to delete map cache files?" || exit 0
set -x
# Clear map tile cache only after successful import.
[ -d /var/lib/mod_tile/ajt ] && rm -rf /var/lib/mod_tile/ajt && chown -R _renderd:_renderd /var/lib/mod_tile
[ -d /var/cache/renderd/tiles/ajt ] && rm -rf /var/cache/renderd/tiles/ajt && chown -R _renderd:_renderd /var/cache/renderd
# Restart renderd to forget the cache.
systemctl restart renderd

View file

@ -1,112 +0,0 @@
#!/usr/bin/env bash
MERGED_TMP_FILE=/tmp/wrolpi-merged.osm.pbf
if [ ! -f /opt/openstreetmap-carto/openstreetmap-carto.lua ]; then
echo "openstreetmap-carto.lua file is missing. Has install been completed?"
exit 1
fi
if [ ! -f /opt/openstreetmap-carto/openstreetmap-carto.style ]; then
echo "openstreetmap-carto.style file is missing. Has install been completed?"
exit 2
fi
if [ "${1}" == "" ]; then
echo "Missing file argument."
exit 3
fi
set -x
HAS_ICE_SHEET=false
sudo -iu postgres psql --port=5433 gis -c '\d' | grep icesheet_polygons && HAS_ICE_SHEET=true
if [ ${HAS_ICE_SHEET} = false ]; then
echo "WROLPi: Missing icesheet_polygons. Run reset_map.sh"
exit 4
fi
# Re-execute this script if it wasn't called with sudo.
if [ $EUID != 0 ]; then
sudo "$0" "$@"
exit $?
fi
function cleanup() {
if [ -f ${MERGED_TMP_FILE} ]; then
rm ${MERGED_TMP_FILE}
fi
}
trap cleanup EXIT
cleanup
systemctl stop renderd
if [[ ${1} == *.osm.pbf ]]; then
# Import PBF files.
for i in "$@"; do
if [[ $i != *.osm.pbf ]]; then
echo "WROLPi: Cannot mix file types"
exit 5
fi
if [ ! -f "${i}" ]; then
echo "WROLPi: File does not exist! ${i}"
exit 6
fi
done
# Use 1/4 of the RAM to import. 1/2 causes crashes on RPi.
RAM_KB=$(grep MemTotal /proc/meminfo | awk '{print $2}')
MAX_CACHE=$((RAM_KB / 1024 / 4))
pbf_path=${1}
pbf_paths=($@)
if [[ ${#pbf_paths[@]} -gt 1 ]]; then
# More than one PBF, merge them before import.
nice -n 18 osmium merge $@ -o ${MERGED_TMP_FILE}
pbf_path=${MERGED_TMP_FILE}
fi
# Import as postgres user, then change ownership to _renderd.
nice -n 18 sudo -iu postgres osm2pgsql -d gis --create --slim -G --hstore --port=5433 \
--tag-transform-script /opt/openstreetmap-carto/openstreetmap-carto.lua \
-C ${MAX_CACHE} \
--number-processes 3 \
-S /opt/openstreetmap-carto/openstreetmap-carto.style \
"${pbf_path}"
# Assign all data to _renderd so the map can be rendered.
sudo -iu postgres psql --port=5433 -d gis -c 'ALTER TABLE external_data OWNER TO _renderd'
sudo -iu postgres psql --port=5433 -d gis -c 'ALTER TABLE geography_columns OWNER TO _renderd'
sudo -iu postgres psql --port=5433 -d gis -c 'ALTER TABLE geometry_columns OWNER TO _renderd'
sudo -iu postgres psql --port=5433 -d gis -c "ALTER TABLE icesheet_outlines OWNER TO _renderd"
sudo -iu postgres psql --port=5433 -d gis -c "ALTER TABLE icesheet_polygons OWNER TO _renderd"
sudo -iu postgres psql --port=5433 -d gis -c "ALTER TABLE ne_100m_admin_0_boundary_lines_land OWNER TO _renderd"
sudo -iu postgres psql --port=5433 -d gis -c "ALTER TABLE planet_osm_line OWNER TO _renderd"
sudo -iu postgres psql --port=5433 -d gis -c "ALTER TABLE planet_osm_nodes OWNER TO _renderd"
sudo -iu postgres psql --port=5433 -d gis -c "ALTER TABLE planet_osm_point OWNER TO _renderd"
sudo -iu postgres psql --port=5433 -d gis -c "ALTER TABLE planet_osm_polygon OWNER TO _renderd"
sudo -iu postgres psql --port=5433 -d gis -c "ALTER TABLE planet_osm_rels OWNER TO _renderd"
sudo -iu postgres psql --port=5433 -d gis -c "ALTER TABLE planet_osm_roads OWNER TO _renderd"
sudo -iu postgres psql --port=5433 -d gis -c "ALTER TABLE planet_osm_ways OWNER TO _renderd"
sudo -iu postgres psql --port=5433 -d gis -c "ALTER TABLE simplified_water_polygons OWNER TO _renderd"
sudo -iu postgres psql --port=5433 -d gis -c "ALTER TABLE spatial_ref_sys OWNER TO _renderd"
sudo -iu postgres psql --port=5433 -d gis -c "ALTER TABLE water_polygons OWNER TO _renderd"
elif [[ ${1} == *.dump ]]; then
if [ ! -f "${1}" ]; then
echo "WROLPi: File does not exist! ${1}"
exit 7
fi
# Import a Postgresql dump.
nice -n 18 pg_restore --port=5433 -j3 --no-owner -d gis -U _renderd -h 127.0.0.1 "${1}"
else
echo "WROLPi: Cannot import unknown file"
exit 8
fi
# Clear map tile cache only after successful import.
yes | /bin/bash /opt/wrolpi/scripts/clear_map_cache.sh
# Use wget to fetch the first few layers of map tiles so the map is ready to use.
# Failure does not mean the import failed.
bash /opt/wrolpi/wrolpi/scripts/initialize_map_tiles.sh || :

View file

@ -1,41 +0,0 @@
#!/usr/bin/env bash
# Creates the gis (map) database and _renderd database user if they don't exist.
# WARNING: This will overwrite the map database data.
source /opt/wrolpi/wrolpi/scripts/lib.sh
sudo -iu postgres psql -c '\l' 2>/dev/null | grep gis >/dev/null && (
yes_or_no "Are you sure you want to initialize the map database? Data from imported maps will be lost." || exit 0
)
set -x
systemctl stop renderd
# Create map database if it does not exist.
pg_createcluster 15 map --port=5433 --start -e utf8
# Create gis (map) database.
sudo -iu postgres psql -c '\l' --port=5433 | grep gis || (
sudo -iu postgres createuser --port=5433 _renderd
sudo -iu postgres psql --port=5433 -c "alter user _renderd password 'wrolpi'"
sudo -iu postgres createdb --port=5433 -E UTF8 -O _renderd --template=template0 gis
sudo -iu postgres psql -d gis --port=5433 -c 'CREATE EXTENSION postgis'
sudo -iu postgres psql -d gis --port=5433 -c 'CREATE EXTENSION hstore'
echo "Created gis database"
)
# Restore initial dump (handle both gzipped and non-gzipped custom format).
DUMP_FILE=/opt/wrolpi-blobs/map-db-gis.dump
if file "${DUMP_FILE}" | grep -q "gzip"; then
echo "Restoring gzipped dump..."
gunzip -c "${DUMP_FILE}" | sudo -iu postgres pg_restore --port=5433 --no-owner --role=_renderd -d gis
else
echo "Restoring dump..."
sudo -iu postgres pg_restore --port=5433 --no-owner --role=_renderd -d gis -j3 "${DUMP_FILE}"
fi
sudo -iu postgres psql --port=5433 -d gis -c 'ALTER TABLE geography_columns OWNER TO _renderd'
sudo -iu postgres psql --port=5433 -d gis -c 'ALTER TABLE geometry_columns OWNER TO _renderd'
sudo -iu postgres psql --port=5433 -d gis -c 'ALTER TABLE spatial_ref_sys OWNER TO _renderd'
# Clear map tile cache files.
yes | /bin/bash /opt/wrolpi/scripts/clear_map_cache.sh

View file

@ -14,7 +14,7 @@ node -v
npm -v
# Install serve, and archiving tools.
single-file --version || sudo npm i -g serve@12.0.1 single-file-cli@2.0.73 readability-extractor@0.0.6 carto@1.2.0
single-file --version || sudo npm i -g serve@12.0.1 single-file-cli@2.0.73 readability-extractor@0.0.6
# Build React app in background job.
cd /opt/wrolpi/app || exit 5
@ -27,18 +27,6 @@ python3 -m venv /opt/wrolpi/venv
# Create the WROLPi user
grep wrolpi: /etc/passwd || useradd -md /home/wrolpi wrolpi -s "$(command -v bash)"
# Get map dependencies.
[ -d /opt/openstreetmap-carto ] && chown -R wrolpi:wrolpi /opt/openstreetmap-carto
git clone https://github.com/lrnselfreliance/openstreetmap-carto.git /opt/openstreetmap-carto || :
git config --global --add safe.directory /opt/openstreetmap-carto
(cd /opt/openstreetmap-carto && git fetch && git checkout master && git reset --hard origin/master && git pull --ff)
chown -R _renderd:_renderd /opt/openstreetmap-carto
# Get map initialization dump.
if [[ ! -f /opt/wrolpi-blobs/map-db-gis.dump || ! -s /opt/wrolpi-blobs/map-db-gis.dump ]]; then
wget https://wrolpi.nyc3.cdn.digitaloceanspaces.com/map-db-gis.dump -O /opt/wrolpi-blobs/map-db-gis.dump
fi
# Install Caddy from official apt repo if not already installed.
if ! command -v caddy &>/dev/null; then
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg

114
scripts/install_protomaps.sh Executable file
View file

@ -0,0 +1,114 @@
#!/usr/bin/env bash
# Installs PMTiles tools and migrates from the old Leaflet/renderd/Apache2 map stack.
# This script is idempotent — safe to run multiple times.
# Called by upgrade.sh during the upgrade process.
set -e
set -x
# --- Install/upgrade pmtiles CLI ---
install_pmtiles() {
PMTILES_VERSION="v1.30.1"
ARCH=$(uname -m)
if [ "$ARCH" = "aarch64" ]; then
PMTILES_ARCH="arm64"
elif [ "$ARCH" = "x86_64" ]; then
PMTILES_ARCH="amd64"
else
echo "Unsupported architecture for pmtiles: $ARCH"
return 1
fi
# Check if already installed at correct version.
if command -v pmtiles &>/dev/null; then
CURRENT=$(pmtiles version 2>&1 | head -1 | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' || echo "")
if [ "$CURRENT" = "$PMTILES_VERSION" ]; then
echo "pmtiles ${PMTILES_VERSION} already installed"
return 0
fi
fi
echo "Installing pmtiles ${PMTILES_VERSION} for ${ARCH}..."
curl -fsSL "https://github.com/protomaps/go-pmtiles/releases/download/${PMTILES_VERSION}/go-pmtiles_${PMTILES_VERSION#v}_Linux_${PMTILES_ARCH}.tar.gz" \
| tar -xz -C /usr/local/bin/ pmtiles
chmod +x /usr/local/bin/pmtiles
pmtiles version
}
install_pmtiles || echo "pmtiles CLI installation failed, continuing..."
# --- Migrate from old map stack (runs once) ---
MARKER_FILE="/opt/wrolpi/.protomaps_installed"
if [ -f "${MARKER_FILE}" ]; then
echo "Protomaps migration already completed."
exit 0
fi
echo "Migrating map stack to Protomaps (MapLibre GL JS + PMTiles)..."
# --- Step 1: Stop and disable old map services ---
echo "Stopping old map services..."
systemctl stop renderd 2>/dev/null || :
systemctl stop apache2 2>/dev/null || :
systemctl stop postgresql@15-map.service 2>/dev/null || :
systemctl disable renderd 2>/dev/null || :
systemctl disable apache2 2>/dev/null || :
systemctl disable postgresql@15-map.service 2>/dev/null || :
# --- Step 2: Uninstall old map packages ---
echo "Removing old map packages..."
apt-get remove -y --purge apache2 apache2-dev apache2-doc libapache2-mod-tile renderd osm2pgsql 2>/dev/null || :
apt-get autoremove -y 2>/dev/null || :
# --- Step 3: Drop the map PostgreSQL cluster ---
echo "Removing map PostgreSQL cluster..."
if pg_lsclusters 2>/dev/null | grep -q "15.*map"; then
pg_dropcluster --stop 15 map 2>/dev/null || :
fi
# Remove the map database blob (no longer needed, saves ~1.2 GB).
if [ -f /opt/wrolpi-blobs/map-db-gis.dump ]; then
chattr -i /opt/wrolpi-blobs/map-db-gis.dump 2>/dev/null || :
rm -f /opt/wrolpi-blobs/map-db-gis.dump
echo "Removed map-db-gis.dump blob."
fi
# --- Step 4: Clean up old config files ---
rm -f /etc/renderd.conf
rm -f /etc/apache2/ports.conf
rm -f /etc/apache2/conf-available/mod_tile.conf
rm -f /etc/apache2/sites-available/000-default.conf
rm -rf /etc/systemd/system/postgresql@15-map.service.d
rm -f /var/www/html/leaflet.js /var/www/html/leaflet.css
# Remove old .pgpass entry for the map database.
if [ -f /home/wrolpi/.pgpass ]; then
sed -i '/5433/d' /home/wrolpi/.pgpass
fi
# --- Step 5: Update wrolpi.target to remove old services ---
# The target file is copied from the repo by repair.sh, but update the installed copy now.
if [ -f /etc/systemd/system/wrolpi.target ]; then
sed -i 's/ renderd\.service//' /etc/systemd/system/wrolpi.target
sed -i 's/ apache2\.service//' /etc/systemd/system/wrolpi.target
sed -i 's/ postgresql@15-map\.service//' /etc/systemd/system/wrolpi.target
fi
systemctl daemon-reload
# --- Step 6: Mark migration as complete ---
touch "${MARKER_FILE}"
chown wrolpi:wrolpi "${MARKER_FILE}"
echo "Protomaps migration completed successfully."
echo "Map files (.pmtiles) should be placed in /media/wrolpi/map/"
echo "The map viewer is served by Caddy on port 8084."

View file

@ -14,7 +14,7 @@ node -v
npm -v
# Install serve, and archiving tools.
single-file --version || sudo npm i -g serve@12.0.1 single-file-cli@2.0.73 readability-extractor@0.0.6 carto@1.2.0
single-file --version || sudo npm i -g serve@12.0.1 single-file-cli@2.0.73 readability-extractor@0.0.6
# Build React app in background job.
cd /opt/wrolpi/app || exit 5
@ -27,18 +27,6 @@ python3 -m venv /opt/wrolpi/venv
# Create the WROLPi user
grep wrolpi: /etc/passwd || useradd -md /home/wrolpi wrolpi -s "$(command -v bash)"
# Get map dependencies.
[ -d /opt/openstreetmap-carto ] && chown -R wrolpi:wrolpi /opt/openstreetmap-carto
git clone https://github.com/lrnselfreliance/openstreetmap-carto.git /opt/openstreetmap-carto || :
git config --global --add safe.directory /opt/openstreetmap-carto
(cd /opt/openstreetmap-carto && git fetch && git checkout master && git reset --hard origin/master && git pull --ff)
chown -R _renderd:_renderd /opt/openstreetmap-carto
# Get map initialization dump.
if [[ ! -f /opt/wrolpi-blobs/map-db-gis.dump || ! -s /opt/wrolpi-blobs/map-db-gis.dump ]]; then
wget https://wrolpi.nyc3.cdn.digitaloceanspaces.com/map-db-gis.dump -O /opt/wrolpi-blobs/map-db-gis.dump
fi
# Install Caddy from official apt repo if not already installed.
if ! command -v caddy &>/dev/null; then
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg

View file

@ -1,107 +0,0 @@
#! /usr/bin/env python3
"""Used to download many map tiles from the Map service into the current directory.
Example: To download all tiles of the US state of Kansas, run the script like so:
/opt/wrolpi/venv/bin/python /opt/wrolpi/scripts/map_download_tiles.py 40.011647534727125 -102.06383712982996 37.030883772380065 -94.61534551981345
The script will download zoom levels 6 to 12 by default, this will show most of a US state down to major streets.
Changing zoom levels can be exponential!
"""
import argparse
import pathlib
from math import log, tan, cos, pi
import requests
import urllib3
from tqdm import tqdm
# urllib3 reports a warning whenever you make an insecure request, the line below disables that functionality.
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
def latitude_to_tile_y(lat: float, zoom: int) -> int:
return int((1.0 - log(tan(lat * pi / 180.0) + 1.0 / cos(lat * pi / 180.0)) / pi) / 2.0 * (1 << zoom))
def longitude_to_tile_x(lon: float, zoom: int) -> int:
return int((lon + 180.0) / 360.0 * (1 << zoom))
def get_tile(host: str, zoom: int, x: int, y: int) -> bytes:
response = requests.get(f"{host}/{zoom}/{x}/{y}.png", verify=False, timeout=5 * 60)
if response.status_code != 200:
raise RuntimeError(f"Request failed with status code {response.status_code}")
return response.content
def main(
host: str,
zoom_start: int,
zoom_stop: int,
west_latitude: float,
west_longitude: float,
east_latitude: float,
east_longitude: float,
):
grand_total = 0
for zoom in range(zoom_start, zoom_stop + 1):
west_y = latitude_to_tile_y(west_latitude, zoom)
west_x = longitude_to_tile_x(west_longitude, zoom)
east_y = latitude_to_tile_y(east_latitude, zoom)
east_x = longitude_to_tile_x(east_longitude, zoom)
grand_total += len(list(range(west_y, east_y))) * len(list(range(west_x, east_x)))
print(f'Expecting to download {grand_total} tiles...')
for zoom in range(zoom_start, zoom_stop + 1):
west_y = latitude_to_tile_y(west_latitude, zoom)
west_x = longitude_to_tile_x(west_longitude, zoom)
east_y = latitude_to_tile_y(east_latitude, zoom)
east_x = longitude_to_tile_x(east_longitude, zoom)
total = len(list(range(west_y, east_y))) * len(list(range(west_x, east_x)))
with tqdm(total=total) as pbar:
pbar.set_description(f'zoom {zoom}')
for x in range(west_x, east_x + 1):
pathlib.Path(f'{zoom}/{x}').mkdir(parents=True, exist_ok=True)
for y in range(west_y, east_y + 1):
pbar.update(1)
file = pathlib.Path(f'{zoom}/{x}/{y}.png')
if not file.exists() or file.stat().st_size == 0:
tile = get_tile(host, zoom, x, y)
file.write_bytes(tile)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Download map tiles from WROLPi")
parser.add_argument('-H', '--host', type=str,
default='https://localhost:8084/hot',
help='The URL of your map tiles server',
)
parser.add_argument('-a', '--zoom-start', type=int, default=0,
help='The highest zoom to download. 0 will display the entire planet, 6 will display display most of a US state.')
parser.add_argument('-o', '--zoom-stop', type=int, default=12,
help='The lowest zoom to download. 12 will show major streets, 13 will show small streets, 14 will show walking paths.')
parser.add_argument('west_latitude', type=float,
help='The west-most (leftmost) latitude of the square you want to download. Example: 40.011647534727125',
)
parser.add_argument('west_longitude', type=float,
help='The west-most (leftmost) longitude of the square you want to download. Example: -102.06383712982996',
)
parser.add_argument('east_latitude', type=float,
help='The west-most (leftmost) longitude of the square you want to download. Example: 37.030883772380065',
)
parser.add_argument('east_longitude', type=float,
help='The west-most (leftmost) longitude of the square you want to download. Example: -94.61534551981345',
)
args = parser.parse_args()
main(
host=args.host,
zoom_start=args.zoom_start,
zoom_stop=args.zoom_stop,
west_latitude=args.west_latitude,
west_longitude=args.west_longitude,
east_latitude=args.east_latitude,
east_longitude=args.east_longitude,
)

View file

@ -1,60 +0,0 @@
#!/usr/bin/env bash
source /opt/wrolpi/wrolpi/scripts/lib.sh
# Re-execute this script if it wasn't called with sudo.
if [ $EUID != 0 ]; then
sudo "$0" "$@"
exit $?
fi
# Change directory to avoid "sudo" home directory warning.
cd /tmp
if sudo -iu postgres psql --port=5433 -l 2>/dev/null | grep gis >/dev/null; then
yes_or_no "Are you sure you want to delete the map database and cache? This can't be undone!" || exit 0
fi
function cleanup() {
sudo rm -f /tmp/tile.png /tmp/tile.md5
}
trap cleanup EXIT
cleanup
set -e
set -x
systemctl stop renderd
# Delete old map database, if it exists.
sudo -iu postgres dropdb --port=5432 gis || :
sudo -iu postgres dropuser --port=5432 _renderd || :
# Delete new map database, it will be created again.
sudo -iu postgres dropdb --port=5433 gis || :
sudo -iu postgres dropuser --port=5433 _renderd || :
# Reset "imported" status of any map files in API DB.
sudo -iu postgres psql -d wrolpi -c "UPDATE map_file SET imported=false"
yes | /opt/wrolpi/scripts/initialize_map_db.sh
# Use curl to fetch the first few layers of map tiles so the map is ready to use.
bash /opt/wrolpi/wrolpi/scripts/initialize_map_tiles.sh
# Check the hash value of a Washington DC tile from /opt/wrolpi-blobs/map-db-gis.dump
wget "https://127.0.0.1:8084/hot/13/2345/3134.png" \
--quiet \
--no-check-certificate \
--timeout 600 \
-O /tmp/tile.png
set +x
echo "58b261940abaf50229544839fc55c83d /tmp/tile.png" > /tmp/tile.md5
if md5sum -c /tmp/tile.md5 >/dev/null 2>&1 ; then
echo "Map tile was rendered correctly"
else
echo "Map tile was not rendered correctly!"
exit 1
fi
echo "Map has been reset."

View file

@ -87,19 +87,27 @@ find /opt/wrolpi/venv -name "*.pyc" -delete 2>/dev/null || :
# Upgrade WROLPi Help.
/opt/wrolpi/scripts/install_help_service.sh || echo "Help install failed."
# Get map db blob, if it is missing.
MAP_DB_BLOB=/opt/wrolpi-blobs/map-db-gis.dump
if [[ ! -f ${MAP_DB_BLOB} || ! -s ${MAP_DB_BLOB} ]]; then
echo "Downloading new map blob (1.2 GB)..."
wget https://wrolpi.nyc3.cdn.digitaloceanspaces.com/map-db-gis.dump -O ${MAP_DB_BLOB}
fi
if [[ -f /opt/wrolpi-blobs/gis-map.dump.gz && -s ${MAP_DB_BLOB} ]]; then
# Remove old blob now that we have the new one.
rm /opt/wrolpi-blobs/gis-map.dump.gz
fi
# Migrate from old Leaflet/renderd/Apache2 map stack to MapLibre GL JS + PMTiles.
/opt/wrolpi/scripts/install_protomaps.sh || echo "Protomaps migration failed."
# Migrate map DB if necessary. Do this before repair because it will reset map if map db is empty.
/opt/wrolpi/wrolpi/scripts/migrate_map_db.sh || echo "Map DB migration failed."
# Download map fonts blob if missing.
MAP_FONTS_BLOB=/opt/wrolpi-blobs/map-fonts.tar.gz
if [[ ! -f ${MAP_FONTS_BLOB} || ! -s ${MAP_FONTS_BLOB} ]]; then
echo "Downloading map fonts..."
mkdir -p /tmp/map-fonts-dl
curl -fsSL https://github.com/protomaps/basemaps-assets/archive/refs/heads/main.tar.gz \
| tar -xz --strip-components=1 -C /tmp/map-fonts-dl basemaps-assets-main/fonts
tar -czf "${MAP_FONTS_BLOB}" -C /tmp/map-fonts-dl fonts
rm -rf /tmp/map-fonts-dl
fi || echo "Map fonts download failed, continuing..."
# Download map overview blob if missing (42 MB, provides global zoom 0-6).
MAP_OVERVIEW_BLOB=/opt/wrolpi-blobs/map-overview.pmtiles
if [[ ! -f ${MAP_OVERVIEW_BLOB} || ! -s ${MAP_OVERVIEW_BLOB} ]]; then
echo "Downloading map overview..."
curl -fsSL https://wrolpi.nyc3.cdn.digitaloceanspaces.com/maps/map-overview.pmtiles \
-o "${MAP_OVERVIEW_BLOB}"
fi || echo "Map overview download failed, continuing..."
# Migrate from nginx to Caddy if necessary.
if ! command -v caddy &>/dev/null; then