mapcomplete/scripts/osm2pgsql/update.sh

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

36 lines
1 KiB
Bash
Raw Normal View History

2024-03-28 10:37:58 +01:00
#! /bin/bash
2024-09-02 00:46:25 +02:00
# Full database update. Downloads the latest from planet.osm.org, build update script, setup and seed it
# Meant to be run with 'nohup'
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/
2024-09-02 01:24:38 +02:00
cd ~/data || exit
rm planet-latest.osm.pbf
wget https://planet.osm.org/pbf/planet-latest.osm.pbf
2024-08-20 12:05:15 +02:00
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
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-09-02 00:43:13 +02:00
cd ~/git/MapComplete || exit
2024-08-20 12:05:15 +02:00
npm run delete:database:old
2024-09-02 00:43:13 +02:00
nohup npm run server:summary >> summary_server.log &
cd - || exit
2024-08-20 12:05:15 +02:00
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 &