3 # Script to set up Nominatim database for multiple countries
7 # *) Get the pbf files from server
9 # *) Set up sequence.state for updates
11 # *) Merge the pbf files into a single file.
13 # *) Setup nominatim db using 'setup.php --osm-file'
17 # Use "bashdb ./update_database.sh" and bashdb's "next" command for step-by-step
20 # ******************************************************************************
22 touch2() { mkdir -p "$(dirname "$1")" && touch "$1" ; }
24 # ******************************************************************************
25 # Configuration section: Variables in this section should be set according to your requirements
27 # REPLACE WITH LIST OF YOUR "COUNTRIES":
29 COUNTRIES="europe/monaco europe/andorra"
31 # SET TO YOUR NOMINATIM build FOLDER PATH:
33 NOMINATIMBUILD="/srv/nominatim/build"
34 SETUPFILE="$NOMINATIMBUILD/utils/setup.php"
35 UPDATEFILE="$NOMINATIMBUILD/utils/update.php"
37 # SET TO YOUR update FOLDER PATH:
39 UPDATEDIR="/srv/nominatim/update"
41 # SET TO YOUR replication server URL:
43 BASEURL="https://download.geofabrik.de"
44 DOWNCOUNTRYPOSTFIX="-latest.osm.pbf"
46 # End of configuration section
47 # ******************************************************************************
49 COMBINEFILES="osmium merge"
57 for COUNTRY in $COUNTRIES;
60 echo "===================================================================="
62 echo "===================================================================="
63 DIR="$UPDATEDIR/$COUNTRY"
64 FILE="$DIR/configuration.txt"
65 DOWNURL="$BASEURL/$COUNTRY$DOWNCOUNTRYPOSTFIX"
66 IMPORTFILE=$COUNTRY$DOWNCOUNTRYPOSTFIX
67 IMPORTFILEPATH=${UPDATEDIR}/tmp/${IMPORTFILE}
68 FILENAME=${COUNTRY//[\/]/_}
71 touch2 $IMPORTFILEPATH
72 wget ${DOWNURL} -O $IMPORTFILEPATH
74 touch2 ${DIR}/sequence.state
75 pyosmium-get-changes -O $IMPORTFILEPATH -f ${DIR}/sequence.state -v
77 COMBINEFILES="${COMBINEFILES} ${IMPORTFILEPATH}"
79 echo "===================================================================="
83 echo "${COMBINEFILES} -o combined.osm.pbf"
84 ${COMBINEFILES} -o combined.osm.pbf
86 echo "===================================================================="
87 echo "Setting up nominatim db"
88 ${SETUPFILE} --osm-file ${UPDATEDIR}/tmp/combined.osm.pbf --all 2>&1
90 # ${UPDATEFILE} --import-file ${UPDATEDIR}/tmp/combined.osm.pbf 2>&1
91 echo "===================================================================="