Skip to content

Instantly share code, notes, and snippets.

@panpomaly
Forked from mdeweerd/update_database.sh
Last active June 21, 2018 09:31
Show Gist options
  • Save panpomaly/fb1881ffb127407a15549d60980accc5 to your computer and use it in GitHub Desktop.
Save panpomaly/fb1881ffb127407a15549d60980accc5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
### Country list
# CHANGE WITH YOUR COUNTRIES
COUNTRIES="europe/france/guadeloupe europe/france/guyane europe/france/mayotte europe/france/martinique europe/france/reunion europe/france"
# SMALL SUBSET FOR TESTING:
#COUNTRIES="europe/france/guyane europe/france/mayotte"
# Set to nominatim build dir
NOMINATIM="/var/www/Nominatim"
INDEX=0 # false
### Foreach country check if configuration exists (if not create one) and then import the diff
for COUNTRY in $COUNTRIES;
do
DIR="$NOMINATIM/updates/$COUNTRY"
FILE="$DIR/configuration.txt"
if [ ! -f "${FILE}" ];
then
/bin/mkdir -p "${DIR}"
/usr/bin/osmosis --rrii workingDirectory="${DIR}/."
/bin/echo baseUrl=http://download.geofabrik.de/${COUNTRY}-updates > "${FILE}"
/bin/echo maxInterval = 0 >> "${FILE}"
cd ${DIR}
/usr/bin/wget http://download.geofabrik.de/${COUNTRY}-updates/state.txt
fi
FILENAME=${COUNTRY//[\/]/_}
/usr/bin/osmosis --rri workingDirectory="${DIR}/." --wxc "${DIR}/${FILENAME}.osc.gz"
### Foreach diff files do the import
if [ -f "${DIR}/${FILENAME}.osc.gz" ];
then
"${NOMINATIM}/utils/update.php" --import-diff "${DIR}/${FILENAME}.osc.gz"
rm "${DIR}/${FILENAME}.osc.gz"
INDEX=1
fi
done
### Re-index if needed
if ((${INDEX}));
then
"${NOMINATIM}/utils/update.php" --index
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment