Add PostGIS extension check to Reitti update_script

Automatically enable PostGIS extension on existing installations if missing.
Checks if extension is already enabled before attempting to create it.

Fixes existing Reitti installations that were created before PostGIS was
added to the initial setup (commit b6312b87d).

Users no longer need to manually run 'CREATE EXTENSION postgis;'
This commit is contained in:
CanbiZ
2026-01-05 15:15:59 +01:00
parent e44a8e8af8
commit 6f358d7e5d

View File

@@ -28,6 +28,15 @@ function update_script() {
exit
fi
# Enable PostGIS extension if not already enabled
if systemctl is-active --quiet postgresql; then
if ! sudo -u postgres psql -d reitti -tAc "SELECT 1 FROM pg_extension WHERE extname='postgis'" 2>/dev/null | grep -q 1; then
msg_info "Enabling PostGIS extension"
sudo -u postgres psql -d reitti -c "CREATE EXTENSION IF NOT EXISTS postgis;" &>/dev/null
msg_ok "Enabled PostGIS extension"
fi
fi
if [ ! -d /var/cache/nginx/tiles ]; then
msg_info "Installing Nginx Tile Cache"
mkdir -p /var/cache/nginx/tiles