| 
									
										
										
										
											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-10-12 13:03:39 +02:00
										 |  |  | export NVM_DIR="$HOME/.nvm" | 
					
						
							|  |  |  | [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm | 
					
						
							| 
									
										
										
										
											2024-10-12 12:59:06 +02:00
										 |  |  | nvm use 20.12.2 | 
					
						
							| 
									
										
										
										
											2024-08-20 12:05:15 +02:00
										 |  |  | 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-09-10 13:35:16 +02:00
										 |  |  | cd ~/git/MapComplete/ || exit | 
					
						
							| 
									
										
										
										
											2024-08-21 01:15:25 +02:00
										 |  |  | npm run create:database -- -- ${DATE/T.*//} | 
					
						
							| 
									
										
										
										
											2024-09-10 13:35:16 +02:00
										 |  |  | cd ~/data || exit | 
					
						
							| 
									
										
										
										
											2024-08-19 19:09:16 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | rm seeddb.log | 
					
						
							| 
									
										
										
										
											2024-09-10 14:26:44 +02:00
										 |  |  | osm2pgsql -O flex -S build_db.lua -s --flat-nodes=import-help-file -d postgresql://user:password@localhost:5444/osm-poi.${DATE} 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 & |