-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(docker_build_script): improve bash error checking, relax pbf exte…
…nsion pattern matching
- Loading branch information
1 parent
f2ab02b
commit c7122d5
Showing
1 changed file
with
35 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |