Skip to content

Commit

Permalink
fix(docker_build_script): improve bash error checking, relax pbf exte…
Browse files Browse the repository at this point in the history
…nsion pattern matching
  • Loading branch information
missinglink committed Sep 29, 2021
1 parent f2ab02b commit c7122d5
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions docker_build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,40 @@
#!/bin/bash

# update ENV vars to point to the first available file on disk
export PBF2JSON_FILE=$(ls ${OSMPATH}/*.osm.pbf | head -n 1)
export POLYLINE_FILE=$(ls ${POLYLINEPATH}/*.0sv | head -n 1)
# ensure environment variables are set
if [[ -z "${OSMPATH}" ]]; then
2>&1 echo "error: environment variable OSMPATH not set"
exit 1
fi
if [[ -z "${POLYLINEPATH}" ]]; then
2>&1 echo "error: environment variable POLYLINEPATH not set"
exit 1
fi

# read a list of available pbf/0sv files
shopt -s nullglob
PBF_FILES=(${OSMPATH}/*.pbf)
POLYLINE_FILES=(${POLYLINEPATH}/*.0sv)
shopt -u nullglob

# ensure at least one *.pbf file exists, warn if more than one was found
if [[ ${#PBF_FILES[@]} -eq 0 ]]; then
2>&1 echo "error: no .pbf files found in ${OSMPATH}"
exit 1
elif [[ ${#PBF_FILES[@]} -gt 1 ]]; then
2>&1 echo "warning: multiple .pbf files found in ${OSMPATH}, only ${PBF_FILES[0]} was used"
fi

# ensure at least one *.0sv file exists, warn if more than one was found
if [[ ${#POLYLINE_FILES[@]} -eq 0 ]]; then
2>&1 echo "error: no .0sv files found in ${POLYLINEPATH}"
exit 1
elif [[ ${#POLYLINE_FILES[@]} -gt 1 ]]; then
2>&1 echo "warning: multiple .0sv files found in ${POLYLINEPATH}, only ${POLYLINE_FILES[0]} was used"
fi

# update ENV vars to point to the first available files on disk
export PBF2JSON_FILE="${PBF_FILES[0]}"
export POLYLINE_FILE="${POLYLINE_FILES[0]}"

# run the build
exec ./script/build.sh

0 comments on commit c7122d5

Please sign in to comment.