5 if [[ "x$FNAME" == "x" ]]; then
6 echo "Usage: overpass-import-db <OSM file>"
11 *.gz) UNPACKER='gunzip -c' ;;
12 *.bz2) UNPACKER='bunzip2 -c' ;;
13 *) UNPACKER='osmium cat -o - -f xml' ;;
16 <% if node[:overpass][:meta_mode] == "meta" -%>
18 <% elsif node[:overpass][:meta_mode] == "attic" -%>
24 sudo systemctl stop overpass-area-processor.timer || true
25 sudo systemctl stop overpass-update || true
26 sudo systemctl stop overpass-area-dispatcher || true
27 sudo systemctl stop overpass-dispatcher || true
32 sudo -u <%= @username %> rm -rf <%= @basedir %>/db/*
34 $UNPACKER $FNAME | sudo -u <%= @username %> <%= @basedir %>/bin/update_database --db-dir='<%= @basedir %>/db' --compression-method=<%= node[:overpass][:compression_mode] %> --map-compression-method=<%= node[:overpass][:compression_mode] %> $META
36 sudo -u <%= @username %> ln -s <%= @srcdir %>/rules <%= @basedir %>/db/rules
38 echo "Import finished. Catching up with new changes."
40 sudo systemctl start overpass-dispatcher
41 sudo systemctl start overpass-area-dispatcher
43 PYOSMIUM="sudo -u <%= @username %> pyosmium-get-changes --server <%= node[:overpass][:replication_url] %> -f <%= @basedir %>/db/replicate-id"
44 <% if node[:overpass][:meta_mode] == "attic" -%>
45 PYOSMIUM="$PYOSMIUM --no-deduplicate"
48 # Get the replication id
49 $PYOSMIUM -v -O $FNAME --ignore-osmosis-headers
51 sudo -u <%= @username %> rm -f <%= @basedir %>/diffs/*
53 while $PYOSMIUM -v -s 1000 -o <%= @basedir %>/diffs/latest.osc; do
54 if [ ! -f <%= @basedir %>/db/replicate-id ]; then
55 echo "Replication ID not written."
58 DATA_VERSION=`osmium fileinfo -e -g data.timestamp.last <%= @basedir %>/diffs/latest.osc`
59 echo "Downloaded up to timestamp $DATA_VERSION"
60 while ! sudo -u <%= @username %> <%= @basedir %>/bin/update_from_dir --osc-dir=<%= @basedir %>/diffs --version=$DATA_VERSION $META --flush-size=0; do
61 echo "Error while updating. Retry in 1 min."
64 sudo -u <%= @username %> rm <%= @basedir %>/diffs/latest.osc
65 echo "Finished up to $DATA_VERSION."
68 echo "DB up-to-date. Processing areas."
70 sudo -u <%= @username %> <%= @basedir %>/bin/osm3s_query --progress --rules <<%= @srcdir %>/rules/areas.osm3s
72 echo "All updates done."
74 sudo systemctl start overpass-area-processor.timer