Automate setting up a cache server

This commit is contained in:
Pieter Vander Vennet 2024-08-19 19:09:16 +02:00
parent 752266ee48
commit 6f85db291a
6 changed files with 297 additions and 123 deletions

View file

@ -1,8 +1,26 @@
#! /bin/bash
# Full database update. DOwnload latest from planet.osm.org, build update script, setup and seed it
npm run init
npm run generate
npm run refresh:layeroverview
npm run generate:buildDbScript
mv build_db.sh ~/data/
transmission-cli https://planet.osm.org/pbf/planet-latest.osm.pbf.torrent -f ./on_data_downloaded.sh &>nohup_transmission.log
TIMESTAMP=$(osmium fileinfo planet-latest.osm.pbf -g header.option.timestamp)
DATE=$(echo $TIMESTAMP | sed "s/T.*//")
vite-node scripts/osm2pgsql/createNewDatabase.ts -- ${DATE/T.*//}
cd ~/data || exit
rm planet-latest.osm.pbf
wget https://planet.osm.org/pbf/planet-latest.osm.pbf
rm seeddb.log
nohup 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
# To see the progress
# tail -f seeddb.log
# Restart tileserver
export DATABASE_URL=postgresql://user:password@localhost:5444/osm-poi.${DATE}
nohup ./pg_tileserv >> pg_tileserv.log &