#!/usr/bin/env bash . /app/utils.sh sleep_build_fail="10" # 10 seconds sleep_build_success="43200" # 12 hours sleep_no_update="3600" # 1 hour sleep_no_region="10" # 10 seconds function wait() { time="$1" action="$2" message="💤 Sleeping $time seconds" [[ -n "$action" ]] && message="$message ($action)" message="$message..." echo "$message" sleep $time } while : do regions="europe/great-britain" style="" [[ -n "$OSMGARMIN_REGIONS" ]] && regions="$OSMGARMIN_REGIONS" [[ -n "$OSMGARMIN_STYLE" ]] && style="$OSMGARMIN_STYLE" regions_array="$(echo $regions | tr ";" "\n")" for region in $regions_array; do if [[ "$(check_osm_update "$region")" == "true" ]]; then /app/build-gmap.sh "$region" "$style" if [[ $? == 0 ]]; then wait $sleep_build_success "build success" else wait $sleep_build_fail "build fail" fi else wait $sleep_no_update "no update" fi done done