forked from mawei/dp
1
0
Fork 0
dp/installer/custom/install_osm_db.sh

35 lines
829 B
Bash
Executable File

export OSM_DIR=/data/media/0/osm
export OSM_LOCATION=$(cat /data/params/d/OsmLocationUrl)
export OSM_LOCATION_TEXT=$(cat /data/params/d/OsmLocationName)
export XZ_MAP_FILE_NAME=${OSM_LOCATION_TEXT}.tar.xz
export XZ_MAP_FILE=${OSM_DIR}/${XZ_MAP_FILE_NAME}
# WD
cd $OSM_DIR
# Remove legacy compressed map file if existing
rm -rf $XZ_MAP_FILE
# Download map file
wget -O ${XZ_MAP_FILE_NAME} ${OSM_LOCATION}
if [[ "$?" != 0 ]]; then
echo "Error downloading map file"
else
echo "Successfully downloaded map file"
# Remove current db dir if existing
rm -rf ${DB_DIR}/db
if [ -d ${OSM_DIR}/${OSM_LOCATION_TEXT} ]; then
rm -rf ${OSM_DIR}/${OSM_LOCATION_TEXT}
fi
# Decompressing
tar -vxf ${XZ_MAP_FILE_NAME}
mv ${OSM_LOCATION_TEXT} db
# Remove compressed map files after expanding
rm -rf $XZ_MAP_FILE
fi