73 lines
1.5 KiB
Bash
73 lines
1.5 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
osm_source_prefix="https://download.geofabrik.de/"
|
|
osm_source_suffix="-latest.osm.pbf"
|
|
osm_source_name="geofabrik"
|
|
|
|
bounds_dir="/data/build/bounds"
|
|
build_dir="/data/build/tmp"
|
|
maps_dir="/data/build/osm/$osm_source_name"
|
|
out_dir="/data/maps"
|
|
styles_dir="/data/styles"
|
|
tiles_dir="/data/build/tiles"
|
|
|
|
function die() {
|
|
echo "Error: $1"
|
|
exit 255
|
|
}
|
|
|
|
function check_osm_region_exists() {
|
|
region="$1"
|
|
exists="true"
|
|
|
|
curl -ILs --fail "$(get_pbf_url "$region")" &> /dev/null
|
|
[[ $? != 0 ]] && exists="false"
|
|
|
|
echo $exists
|
|
}
|
|
|
|
function check_osm_update() {
|
|
region="$1"
|
|
region_path="$maps_dir/$(get_region_shortname "$region").osm.pbf"
|
|
update="true"
|
|
|
|
md5="$(curl -Ls --fail "$(get_pbf_url "$region").md5" | cut -d' ' -f1)"
|
|
|
|
if [[ $? == 0 ]]; then
|
|
if [[ -f "$region_path" ]]; then
|
|
if [[ "$(get_md5 "$region_path")" == "$md5" ]]; then
|
|
update="false"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
echo $update
|
|
}
|
|
|
|
function exec_mkgmap() {
|
|
java -jar /opt/mkgmap/mkgmap.jar $@
|
|
}
|
|
|
|
function exec_splitter() {
|
|
java -jar /opt/splitter/splitter.jar $@
|
|
}
|
|
|
|
function get_md5() {
|
|
file="$1"
|
|
echo "$(md5sum "$file" | cut -d' ' -f1)"
|
|
}
|
|
|
|
function get_md5_dir() {
|
|
dir="$1"
|
|
echo "$(find "$dir" -type f -name "*.*" -exec md5sum {} + | awk '{print $1}' | sort | md5sum)"
|
|
}
|
|
|
|
function get_pbf_url() {
|
|
region="$1"
|
|
echo "${osm_source_prefix}${region}${osm_source_suffix}"
|
|
}
|
|
|
|
function get_region_shortname() {
|
|
region="$1"
|
|
echo "${region##*/}"
|
|
} |