mapcomplete/scripts/osm2pgsql/update.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
910 B
Bash
Raw Normal View History

2024-03-28 10:37:58 +01:00
#! /bin/bash
2024-08-19 19:09:16 +02:00
# Full database update. DOwnload latest from planet.osm.org, build update script, setup and seed it
2024-08-20 12:05:15 +02:00
nvm use
npm run init # contains a 'npm run generate, which builds the layers'
2024-03-28 10:37:58 +01:00
npm run generate:buildDbScript
2024-08-20 12:05:15 +02:00
mv build_db.lua ~/data/
TIMESTAMP=$(osmium fileinfo ~/data/planet-latest.osm.pbf -g header.option.timestamp)
2024-08-19 19:09:16 +02:00
DATE=$(echo $TIMESTAMP | sed "s/T.*//")
2024-08-20 12:05:15 +02:00
echo $DATE
2024-08-21 01:15:25 +02:00
npm run create:database -- -- ${DATE/T.*//}
2024-08-19 19:09:16 +02:00
cd ~/data || exit
rm planet-latest.osm.pbf
wget https://planet.osm.org/pbf/planet-latest.osm.pbf
rm seeddb.log
2024-08-21 01:15:25 +02:00
osm2pgsql -O flex -S build_db.lua -s --flat-nodes=import-help-file -d postgresql://user:password@localhost:5444/osm-poi planet-latest.osm.pbf >> seeddb.log
2024-08-19 19:09:16 +02:00
# To see the progress
# tail -f seeddb.log
2024-08-20 12:05:15 +02:00
npm run delete:database:old
2024-08-19 19:09:16 +02:00
# Restart tileserver
export DATABASE_URL=postgresql://user:password@localhost:5444/osm-poi.${DATE}
nohup ./pg_tileserv >> pg_tileserv.log &