]> git.openstreetmap.org Git - chef.git/blob - cookbooks/nominatim/templates/default/nominatim-update-data.erb
nominatim: complete rework of the setup
[chef.git] / cookbooks / nominatim / templates / default / nominatim-update-data.erb
1 #!/bin/bash
2
3 # DO NOT EDIT - This file is being maintained by Chef
4
5 date "+%c === Downloading and updating latest data from OSM"
6
7 cd <%= @projectdir %>
8
9 # First execute any maintenance task that may be there.
10
11 for task in `find <%= @bindir %>/maintenance -type f`; do
12   date "+%c === Running maintenance task ${task}"
13   . ${task}
14   rm ${task}
15 done
16
17 # Then catch up with the database.
18
19 num_cpus=`cat /proc/cpuinfo | grep -c processor`
20 num_cpus=$((num_cpus - 2))
21 current_load=`cat /proc/loadavg | cut -f 2 -d ' ' | sed 's:\..*::'`
22
23 if [[ $current_load -lt $num_cpus ]]
24 then
25     INST=4
26 else
27     INST=2
28 fi
29
30 nominatim replication --catch-up --threads $INST