#!/bin/bash set -e if [ "$(basename "$(pwd)")" != "work" ] then >&2 echo 'You should call this script within a directory called "work".' exit 1 fi mainUrl='https://download.geofabrik.de/europe/' case "$1" in '') area='groszdeutschland' countries=( austria germany italy switzerland ) ;; 'benelux') area='benelux' countries=( belgium luxembourg netherlands ) ;; 'fast') area='thueringen' mainUrl="${mainUrl}germany/" countries=( thueringen ) ;; 'gus') area='gus' countries=( croatia czech-republic poland slovakia slovenia ) ;; *) >&2 printf 'Unknown option "%s".\n' "$1" exit 1 ;; esac numJobs=$(($(/usr/bin/getconf _NPROCESSORS_ONLN)/2)) if [ ${numJobs} -lt 1 ] then numJobs=1 fi [ -f "sea.zip" ] || \ wget -nd 'http://osm2.pleiades.uni-wuppertal.de/sea/latest/sea.zip' [ -f "bounds.zip" ] || \ wget -nd 'http://osm2.pleiades.uni-wuppertal.de/bounds/latest/bounds.zip' needsRecompilation=false nextId="63240001" for country in "${countries[@]}" do baseName="${country}-latest.osm.pbf" baseNameDir="${country}-latest_dir" dlItem="${mainUrl}${baseName}" if [ ! -e "${baseName}" ] || ! wget -O - "${dlItem}.md5" 2> /dev/null | md5sum -c then rm -f "${baseName}" wget -nd "${dlItem}" needsRecompilation=true fi if [ ! -d "${baseNameDir}" ] then needsRecompilation=true fi if ${needsRecompilation} then if [ -d "${baseNameDir}" ] then if ls "${baseNameDir}" | grep -q '' then rm "${baseNameDir}"/* fi rmdir "${baseNameDir}" fi mkdir "${baseNameDir}" /usr/lib/jvm/java-8-openjdk/jre/bin/java -jar /usr/share/java/splitter/splitter.jar \ --output-dir="${baseNameDir}" \ --mapid="${nextId}" \ "${baseName}" fi nextId=$[ $( ls -1 "${baseNameDir}" | \ grep '^6324....\.osm\.pbf$' | \ cut -d. -f1 | \ sort -n | \ tail -n1 ) +1 ] done if [ ! -d mkgmap-style-sheets ] then git clone 'https://github.com/ligfietser/mkgmap-style-sheets.git' needsRecompilation=true fi git -C mkgmap-style-sheets fetch --all -p if [ "$(git -C mkgmap-style-sheets rev-parse origin/HEAD)" != "$(git -C mkgmap-style-sheets rev-parse HEAD)" ] then git -C mkgmap-style-sheets checkout master git -C mkgmap-style-sheets reset --hard origin/master needsRecompilation=true fi if ${needsRecompilation} then nice /usr/lib/jvm/java-8-openjdk/jre/bin/java -jar /usr/share/java/mkgmap/mkgmap.jar \ --route \ --add-pois-to-lines \ --add-pois-to-areas \ --bounds=bounds.zip \ --precomp-sea=sea.zip \ --generate-sea \ --index \ --gmapsupp \ --family-name="OpenStreetmap mkgmap" \ --area-name="${area}" \ --max-jobs="${numJobs}" \ --remove-ovm-work-files \ --style-file=mkgmap-style-sheets/styles \ --style="generic new" \ "mkgmap-style-sheets/typ/osm generic new/2000.typ" \ $( printf '%s-latest_dir/6324????.osm.pbf\n' "${countries[@]}" ) rm -f 6324????.img fi size=$(stat -c '%s' gmapsupp.img) max_size=$((4*1024*1024*1024)) { printf '%s\n' \ 'To: benachrichtigungen@eckner.net' \ 'From: plasmapaule@gmail.com' \ 'Subject: Karte fertig' \ '' \ 'Deine Karte auf '"$(hostname)"' ist fertig!' if [ ${size} -gt ${max_size} ]; then printf '%s\n' \ 'Die ist aber groeszer als 4GB.' fi } | \ sendmailadvanced -t