diff --git a/osm-garmin/Containerfile b/osm-garmin/Containerfile index 836eca0..aa7669a 100644 --- a/osm-garmin/Containerfile +++ b/osm-garmin/Containerfile @@ -9,4 +9,4 @@ RUN dnf install --assumeyes --setopt=install_weak_deps=False java-1.8.0-openjdk RUN /app/install-mkgmap.sh RUN dnf clean --assumeyes all -CMD ["/app/daemon.sh"] \ No newline at end of file +CMD ["/app/osm-garmin.sh"] \ No newline at end of file diff --git a/osm-garmin/app/build-gmap.sh b/osm-garmin/app/build-gmap.sh index 6f068d2..4c82f2a 100755 --- a/osm-garmin/app/build-gmap.sh +++ b/osm-garmin/app/build-gmap.sh @@ -83,16 +83,8 @@ function cleanup() { rm -f "$build_dir/*" } -function exec_mkgmap() { - java -jar /opt/mkgmap/mkgmap.jar $@ -} - -function exec_splitter() { - java -jar /opt/splitter/splitter.jar $@ -} - function update_bounds() { - function download_bounds() { + function update_bound_item() { type="$1" bounds_url_prefix="https://www.thkukuk.de/osm/data" @@ -101,8 +93,8 @@ function update_bounds() { rm -f "$bounds_dir/$type.zip" } - download_bounds "bounds" - #download_bounds "sea" + update_bound_item "bounds" + update_bound_item "sea" } function update_osm_map() { @@ -149,7 +141,7 @@ if [[ $OSMGARMIN_SKIP_UPDATE_MAPS != "true" ]]; then [[ $is_updates == "false" ]] && is_updates="true" else - echo "⚠️ No updates to \"$region\"" + echo "⚠️ No updates for \"$region\"" fi else echo "⚠️ Region \"$region\" does not exist" diff --git a/osm-garmin/app/daemon.sh b/osm-garmin/app/daemon.sh deleted file mode 100644 index 9934671..0000000 --- a/osm-garmin/app/daemon.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -. /app/utils.sh - -sleep_time=3600 -sleep_time_fail=60 - -function wait() { - delay="$1" - echo "💤 Sleeping $delay seconds..." - sleep $delay -} - -while : -do - /app/build-gmap.sh "$OSMGARMIN_REGIONS" "$OSMGARMIN_STYLE" - - if [[ $? == 0 ]]; then - wait $sleep_time - else - wait $sleep_time_fail - fi -done \ No newline at end of file diff --git a/osm-garmin/app/osm-garmin.sh b/osm-garmin/app/osm-garmin.sh new file mode 100644 index 0000000..de504a0 --- /dev/null +++ b/osm-garmin/app/osm-garmin.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +. /app/utils.sh + +command="$1" +arguments="${@:2}" +me_filename="$(basename "$(realpath -s "$0")")" + +if [[ "$commnad" == "" ]]; then + die "No command given. See '$me_command help'" +fi + +function exec_daemon() { + sleep_time=3600 + sleep_time_fail=60 + + function wait() { + delay="$1" + echo "💤 Sleeping $delay seconds..." + sleep $delay + } + + while : + do + /app/build-gmap.sh "$OSMGARMIN_REGIONS" "$OSMGARMIN_STYLE" + + if [[ $? == 0 ]]; then + wait $sleep_time + else + wait $sleep_time_fail + fi + done +} + +function exec_help() { + echo "$me_filename + +Usage: + $me_filename daemon / $me_filename + Start daemon to build maps periodically + + $me_filename help + Output this usage text +" + + exit 0 +} + +case "$command" in + ""|"daemon") exec_daemon ;; + "help") exec_help ;; + *) + die "Command '$command' not recognized. See '$me_filename help' for help" + ;; +esac diff --git a/osm-garmin/app/utils.sh b/osm-garmin/app/utils.sh index acd3440..2d7dbb8 100644 --- a/osm-garmin/app/utils.sh +++ b/osm-garmin/app/utils.sh @@ -1,8 +1,12 @@ #!/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" +maps_dir="/data/build/osm/$osm_source_name" out_dir="/data/maps" styles_dir="/data/styles" tiles_dir="/data/build/tiles" @@ -40,6 +44,14 @@ function check_osm_update() { 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)" @@ -52,10 +64,10 @@ function get_md5_dir() { function get_pbf_url() { region="$1" - echo "https://download.geofabrik.de/$region-latest.osm.pbf" + echo "${osm_source_prefix}${region}${osm_source_suffix}" } function get_region_shortname() { region="$1" - echo "$(echo "$region" | sed "s/\//./g")" + echo "${region##*/}" } \ No newline at end of file